huge realloc problem with multiple threads

Rich Prohaska prohaska at
Wed Nov 9 05:05:04 PST 2011

the huge realloc protocol is:

   1. allocate address space with mmap.
   2. add the new space to the huge extent tree.
   3. remap the old pages to the new address space with mremap.  this avoid
   a copy.
   4. remove the old address space from the huge extent tree.

the problem occurs when the old address space becomes free during step 3.
 another thread executing this protocol can get this address during the
mmap in step 1.  then we have a race between the first thread removing the
space in step 4 and the second thread adding the space in step 2.

i switched the order of steps 3 and 4 to solve the problem in the
huge_ralloc function.  i moved the huge_dalloc call to before the mremap
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the jemalloc-discuss mailing list