You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Stefan Ruppert <ml...@ruppert-it.de> on 2009/08/11 22:13:40 UTC

Possible data race bug in apr_pools.c:allocator_alloc

Hi all,

currently I run most of my APR based tools against valgrinds helgrind 
tool to check for possible threading problems. Valgrind detected a 
possible data race reading a allocator field:

static APR_INLINE
apr_memnode_t *allocator_alloc(apr_allocator_t *allocator, apr_size_t size)
{
....
     /* First see if there are any nodes in the area we know
      * our node will fit into.
      */
     if (index <= allocator->max_index) {
                  ^^^^^^^^^^^^^^^^^^^^^^^ Possible data race
#if APR_HAS_THREADS
         if (allocator->mutex)
             apr_thread_mutex_lock(allocator->mutex);
#endif /* APR_HAS_THREADS */
....


I think valgrind reports this error correctly since in multi-threaded 
environments the lock needs to be acquired before the if()-block!

Any comments? Should I provide a patch?

Regards,
Stefan