apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brad Nicholes" <BNICHO...@novell.com>
Subject Creating an allocator with no mutex...
Date Fri, 18 Jul 2003 18:52:07 GMT
   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
to be caused by a corrupt pool list.  It has all of the signs of two
threads manipulating the same list at the same time because the list was
not properly protected.  What we discovered was that due to the
following code that is executed when each worker_thread is started, the
per-thread memory pool is created based on an allocator that does not
hold a mutex.

    apr_allocator_max_free_set(allocator, ap_max_mem_free);

    apr_pool_create_ex(&pthrd, pmain, NULL, allocator);
    apr_allocator_owner_set(allocator, pthrd);
    apr_pool_tag(pthrd, "worker_thrd_pool");

    apr_pool_create(&ptrans, pthrd);
    apr_pool_tag(ptrans, "transaction");

    bucket_alloc = apr_bucket_alloc_create(pthrd);

After looking through many of the other MPM's, it appears that most of
them are doing something similar.  In other words, the per-thread pool
that is created when each threads is spun up, is based on an allocator
that does not hold a mutex.  This means that all pool creation,
destruction or manipulation is not thread safe.  The bigger question is,
shouldn't creating an allocator mutex happen automatically whenever it
is running on a threaded OS?


Brad Nicholes
Senior Software Engineer
Novell, Inc., the leading provider of Net business solutions

View raw message