2793 Tatiana A. Nurnberg 2008-08-21 [merge]
Bug#35616: memory overrun on 64-bit linux on setting large values for keybuffer-size
portability fixes
modified:
mysys/safemalloc.c
2792 Mattias Jonsson 2008-08-20
pre push fix of test case for bug#34604
(needed change in 6.0 from 5.1)
modified:
mysql-test/suite/parts/r/partition_special_innodb.result
mysql-test/suite/parts/t/partition_special_innodb.test
=== modified file 'mysys/safemalloc.c'
--- a/mysys/safemalloc.c 2008-05-29 15:44:11 +0000
+++ b/mysys/safemalloc.c 2008-08-21 05:20:27 +0000
@@ -151,9 +151,10 @@ void *_mymalloc(size_t size, const char
my_errno=errno;
sprintf(buff,"Out of memory at line %d, '%s'", lineno, filename);
my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH));
- sprintf(buff,"needed %u byte (%ldk), memory in use: %ld bytes (%ldk)",
- (uint) size, (uint) (size + 1023L) / 1024L,
- sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L);
+ sprintf(buff,"needed %lu byte (%luk), memory in use: %lu bytes (%luk)",
+ (ulong) size, (ulong) (size + 1023L) / 1024L,
+ (ulong) sf_malloc_max_memory,
+ (ulong) (sf_malloc_max_memory + 1023L) / 1024L);
my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH));
}
DBUG_PRINT("error",("Out of memory, in use: %ld at line %d, '%s'",
@@ -391,12 +392,12 @@ void TERMINATE(FILE *file, uint flag)
{
if (file)
{
- fprintf(file, "Warning: Memory that was not free'ed (%ld bytes):\n",
- sf_malloc_cur_memory);
+ fprintf(file, "Warning: Memory that was not free'ed (%lu bytes):\n",
+ (ulong) sf_malloc_cur_memory);
(void) fflush(file);
}
- DBUG_PRINT("safe",("Memory that was not free'ed (%ld bytes):",
- sf_malloc_cur_memory));
+ DBUG_PRINT("safe",("Memory that was not free'ed (%lu bytes):",
+ (ulong) sf_malloc_cur_memory));
while (irem)
{
char *data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) +
@@ -404,29 +405,29 @@ void TERMINATE(FILE *file, uint flag)
if (file)
{
fprintf(file,
- "\t%6lu bytes at 0x%09lx, allocated at line %4u in '%s'",
- (ulong) irem->datasize, (long) data,
- irem->linenum, irem->filename);
+ "\t%6lu bytes at %p, allocated at line %4u in '%s'",
+ (ulong) irem->datasize, data, irem->linenum, irem->filename);
fprintf(file, "\n");
(void) fflush(file);
}
DBUG_PRINT("safe",
- ("%6lu bytes at 0x%09lx, allocated at line %4d in '%s'",
- (ulong) irem->datasize, (long) data,
- irem->linenum, irem->filename));
+ ("%6lu bytes at %p, allocated at line %4d in '%s'",
+ (ulong) irem->datasize,
+ data, irem->linenum, irem->filename));
irem= irem->next;
}
}
/* Report the memory usage statistics */
if (file && flag)
{
- fprintf(file, "Maximum memory usage: %ld bytes (%ldk)\n",
- sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L);
+ fprintf(file, "Maximum memory usage: %lu bytes (%luk)\n",
+ (ulong) sf_malloc_max_memory,
+ (ulong) (sf_malloc_max_memory + 1023L) / 1024L);
(void) fflush(file);
}
- DBUG_PRINT("safe",("Maximum memory usage: %ld bytes (%ldk)",
- sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) /
- 1024L));
+ DBUG_PRINT("safe",("Maximum memory usage: %lu bytes (%luk)",
+ (ulong) sf_malloc_max_memory,
+ (ulong) (sf_malloc_max_memory + 1023L) /1024L));
pthread_mutex_unlock(&THR_LOCK_malloc);
DBUG_VOID_RETURN;
}
@@ -438,6 +439,7 @@ void TERMINATE(FILE *file, uint flag)
This is usefull to call from withing a debugger
*/
+
void sf_malloc_report_allocated(void *memory)
{
struct st_irem *irem;
@@ -447,9 +449,8 @@ void sf_malloc_report_allocated(void *me
sf_malloc_prehunc);
if (data <= (char*) memory && (char*) memory <= data +
irem->datasize)
{
- printf("%lu bytes at 0x%lx, allocated at line %u in '%s'\n",
- (ulong) irem->datasize, (long) data,
- irem->linenum, irem->filename);
+ printf("%lu bytes at %p, allocated at line %u in '%s'\n",
+ (ulong) irem->datasize, data, irem->linenum, irem->filename);
break;
}
}
@@ -489,9 +490,7 @@ static int _checkchunk(register struct s
fprintf(stderr, " discovered at '%s:%d'\n", filename, lineno);
(void) fflush(stderr);
DBUG_PRINT("safe",("Overrun at %p, allocated at %s:%d",
- data,
- irem->filename,
- irem->linenum));
+ data, irem->filename, irem->linenum));
flag=1;
}
return(flag);
| Thread |
|---|
| • bzr push into mysql-6.0 branch (azundris:2792 to 2793) Bug#35616 | Tatiana A. Nurnberg | 21 Aug |