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] |
Hello, In 4cf6c72fd2a482e7499c29162349810029632c3f ('malloc: Rewrite dumped heap for compatibility in __malloc_set_state'), __malloc_set_state was reimplemented, using the following look to detect the first chunk of the heap: /* Find the chunk with the lowest address with the heap. */ mchunkptr chunk = NULL; { size_t *candidate = (size_t *) ms->sbrk_base; size_t *end = (size_t *) (ms->sbrk_base + ms->sbrked_mem_bytes); while (candidate < end) if (*candidate != 0) { chunk = mem2chunk ((void *) (candidate + 1)); break; } else ++candidate; That assumes that the beginning of the heap is zeroed. It happens that in malloc/malloc.c one can read: /* Skip over some bytes to arrive at an aligned position. We don't need to specially mark these wasted front bytes. They will never be accessed anyway because prev_inuse of av->top (and any chunk created from its start) is always true after initialization. */ On Linux the space happens to be zero by luck, but with other kernels that may not be true (it is not with the Hurd). Also, only the 'size' field of the first chunk is initialized by set_head (av->top, (snd_brk - aligned_brk + correction) | PREV_INUSE); So I'd say we need the attached patch, don't we? Samuel
Attachment:
patch
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |