http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47354

           Summary: bitmap_allocator free_list::_M_get never locks mutex
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: gr...@pobox.com


Created attachment 23023
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23023
Add a mutex lock step in bitmap_allocator.cc

On AIX, I received a test failure in
ext/bitmap_allocator/variadic_construct.cc.

terminate called after throwing an instance of
'__gnu_cxx::__concurrence_unlock_
error'
  what():  __gnu_cxx::__concurrence_unlock_error
FAIL: ext/bitmap_allocator/variadic_construct.cc execution test

I was able to trace this back to src/bitmap_allocator.c free_list::_M_get,
which unlocks its mutex, and that unlock causes the abort.  It seems, however,
that no code path ever locks the mutex in the first place.  (The other use of
the mutex use the __scoped_lock type, which does lock.)

Linux allows you to unlock a mutex that was never locked.  AIX, at least 5.3
TL4, gives you EINVAL when you attempt that.  But, it seems to me that the
mutex should be locked.  To this end, I propose the (very simple) patch
attached, which simply adds __bfl_mutex.lock() inside the #ifdef block.

I have inspected the 'trunk' versions of src/bitmap_allocator.cc and
include/ext/bitmap_allocator.h and believe that the problem remains in the
trunk, not just 4.5.2.

Reply via email to