From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9268 invoked by alias); 18 Jan 2011 21:43:36 -0000 Received: (qmail 9253 invoked by uid 22791); 18 Jan 2011 21:43:35 -0000 X-SWARE-Spam-Status: No, hits=-2.9 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Jan 2011 21:43:31 +0000 From: "greed at pobox dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/47354] New: bitmap_allocator free_list::_M_get never locks mutex X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: greed at pobox dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Tue, 18 Jan 2011 23:16:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-01/txt/msg01865.txt.bz2 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: unassigned@gcc.gnu.org ReportedBy: greed@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.