I think we just discovered what the real source of the problem is. It appears that apr_pool_create_ex() is trying to extract the mutex from the wrong allocator when an allocator is specified. When it tries to get the mutex it uses the parent allocator if one was not passed in. If an allocator was passed in then it uses that one instead which is wrong. The mutex from the allocator that was passed in does not protect the parent but the code still manipulates it anyway. This means that two or more threads could overwrite parent->child simply because the wrong mutex was locked or no mutex was locked at all (in our case). The call to apr_allocator_mutex_get() should use "parent->allocator" not "allocator". If you look at apr_pool_destroy() it is doing it correctly. Otherwise this code is not thread safe.
Brad Brad Nicholes Senior Software Engineer Novell, Inc., the leading provider of Net business solutions http://www.novell.com >>> Cliff Woolley <[EMAIL PROTECTED]> Friday, July 18, 2003 1:17:21 PM >>> On Fri, 18 Jul 2003, Brad Nicholes wrote: > Under what circumstances would you want to create an allocator > without a mutex assigned to it? We have been running into a problem > with the NetWare MPM on multi-processor boxes where Apache faults > periodically while trying to destroy the memory pool. The fault appears Jean-Jacques had written me off-list about the same problem a little while ago, and I just wrote back to him about that. You create an allocator with no mutex on it for a pool that will only ever be used to allocate entities (including subpools) in the current thread. In the other MPM's, it's true that each thread pool has no allocator mutex -- because that thread pool will only ever allocate things for that one thread. But the thread pool's parent, which is the process pool in most other MPM's, does have a mutex on it, meaning that sibling lists which are used when creating and destroying new threads /are/ protected by mutex. I'm guessing that what you're seeing is that, since netware has no processes, the one thread that handles creation of other threads has a thread pool (of which the other threads' pools are children) that is missing the mutex it ought to have. I could be wrong though, as my cursory glance through worker and the netware mpm just now did not reveal where the mutex ought to be set. Unfortunately I'm on my way out of town for the weekend right now or I'd look into it more. Hopefully Sander can fill in to the extent that I'm full of shit. :) --Cliff
