Segmentation fault when a custom chunk allocator returns a memory block larger than the chunk size
xqmeng at gmail.com
Mon Jul 28 14:17:57 PDT 2014
I used the new chunk allocator feature to allocate memory from a fixed 2G
memory region. Nevertheless, I got a seg. fault.
The flow of my code is as following: I first use "arenas.extend" mallctl
to create a custom arena. Then I defined custom chunk_alloc() and
chunk_dalloc() on this arena. In the initialization phase of my code, I use
mmap() to reserve a memory region of size 2^32. In the custom
chunk_alloc(), I return the pointer of the 2^32B memory region. Because
lg_chunk is 2^22, I thought this should be fine. But the program ran into
seg. fault within arena_mapbits_unzeroed_set() called
by arena_chunk_init_hard(). On the other hand, if the mmap() reserved a
memory region of size 2^22, everything works fine.
My question is: why does the custom chunk_alloc() always expect a memory
block returned from mmap()/malloc() with the requested size equal to
lg_chunk? I can't figure out what wrong it could be if the returned block
is a multiple of lg_chunk
B.T.W. My code only uses mallocx() for a single 1024B buffer from the
custom. Memory alignment problem shouldn't exist.
Thanks for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the jemalloc-discuss