This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [BZ #10631] Clarify malloc error diagnostics to avoid confusion


On Wed, Sep 19, 2012 at 10:58:40AM -0400, Carlos O'Donell wrote:
[...]
> The point of [] is to be distracting and isolate the strings from
> the full message.

I'm perfectly OK with any kind of quoting that would look like quoting.

> You raise a good point about the error message being overly terse.
> 
> What about this?
> ~~~
> *** Error `free(): invalid next size (fast)' in `./a.out' at 0x084ed538 ***
> ~~~

The addressees of malloc_printerr messages are certainly not those who
read malloc.c daily.  Most of them are regular users who should be able to
understand from these messages where to file a bug.  Another large group
is application programmers who should be able to understand from these
messages what kind of memory allocation error to look for.  Neither of
them are quite interested in gory implementation details, e.g. what kind
of double free or corruption has been detected.  malloc_printerr messages
would fit their purpose better if the most significant information would
be placed first, e.g.

*** Error in `./a.out': %s: %p ***

For example,

$ echo -e '#include <stdlib.h>\nint main(void){void *p=malloc(1);free(p);free(p);return 0;}' |gcc -xc - && ./a.out 
*** glibc detected *** ./a.out: double free or corruption (fasttop): 0x... ***
would better look as
*** Error in `./a.out': double free or corruption (fasttop): 0x... ***

$ echo -e '#include <stdlib.h>\nint main(void){free(malloc(1)+1);return 0;}' |gcc -xc - && ./a.out 
*** glibc detected ** ./a.out: free(): invalid pointer: 0x... ***
would better look as
*** Error in `./a.out': free(): invalid pointer: 0x... ***

JFYI, we have 23 different error messages passed to malloc_printerr:

$ sed -n 's/^\([^(]*malloc_printerr *([^"]*"\([^"]*\)"\|[^"]*\errstr *= *"\([^"]*\)"\).*/\2\3/p' malloc/*.c |sort -u
break adjusted to free malloc space
corrupted double-linked list
double free or corruption (fasttop)
double free or corruption (out)
double free or corruption (!prev)
double free or corruption (top)
free(): corrupted unsorted chunks
free(): invalid next size (fast)
free(): invalid next size (normal)
free(): invalid pointer
free(): invalid size
invalid fastbin entry (free)
malloc_check_get_size: memory corruption
malloc(): corrupted unsorted chunks
malloc(): corrupted unsorted chunks 2
malloc(): memory corruption
malloc(): memory corruption (fast)
malloc(): smallbin double linked list corrupted
malloc: top chunk is corrupt
munmap_chunk(): invalid pointer
realloc(): invalid next size
realloc(): invalid old size
realloc(): invalid pointer


-- 
ldv

Attachment: pgp00000.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]