huge realloc problem with multiple threads
jasone at canonware.com
Wed Nov 9 12:03:25 PST 2011
On 11/09/2011 05:05 AM, Rich Prohaska wrote:
> 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
I just committed a fix that is as you describe. Thanks for the detailed
report, test, and suggested fix! In a strange coincidence, a coworker
started seeing this same failure yesterday, so you saved me some serious
More information about the jemalloc-discuss