From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14941 invoked by alias); 27 Sep 2016 15:29:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 14920 invoked by uid 89); 27 Sep 2016 15:29:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=gcc5, 2967, our, among X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 27 Sep 2016 15:29:18 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F57231B319; Tue, 27 Sep 2016 15:29:17 +0000 (UTC) Received: from localhost (ovpn-116-23.ams2.redhat.com [10.36.116.23]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8RFTGtZ006892; Tue, 27 Sep 2016 11:29:16 -0400 Date: Tue, 27 Sep 2016 15:39:00 -0000 From: Jonathan Wakely To: =?iso-8859-1?Q?Fran=E7ois?= Dumont Cc: "libstdc++@gcc.gnu.org" , gcc-patches Subject: Re: debug container mutex association Message-ID: <20160927152915.GA12862@redhat.com> References: <46b4f297-c0da-b0b0-03ef-bba019b97ec7@gmail.com> <20160914090036.GC17376@redhat.com> <20160915085143.GJ17376@redhat.com> <2af7879c-bef5-7874-b5ae-722ad3a1e171@gmail.com> <20160920085319.GC17376@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="k+w/mQv8wyuph6w0" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20160920085319.GC17376@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.7.0 (2016-08-17) X-SW-Source: 2016-09/txt/msg02018.txt.bz2 --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-length: 993 On 20/09/16 09:53 +0100, Jonathan Wakely wrote: >On 19/09/16 21:56 +0200, François Dumont wrote: >>Hi >> >> Following our conversation here is a much simpler patch. I just >>consider that all debug containers will have the same alignment. >> >> Even if I submit this patch as a whole I will commit into pieces, >>at least one for the pure cleanup parts and one for the debug.cc >>change. >> >> Among those changes there is: >>- __gnu_cxx::__scoped_lock(this->_M_get_mutex()); >>+ __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); >> >> I would appreciate if you could tell me what was happening with >>the initial expression. I don't understand why it is compiling. I >>even tried the same in debug.cc and started having compilation >>errors. > >It creates a temporary __scoped_lock, which immediately goes out of >scope and unlocks the mutex again. This should be fixed on the gcc-5 >and gcc-6 branches too. I'm committing this to the gcc-5 and gcc-6 branches. --k+w/mQv8wyuph6w0 Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 822 commit 5218b515fdb54881d8a2b87c28eb5fd84c52db01 Author: Jonathan Wakely Date: Tue Sep 27 16:22:28 2016 +0100 Fix lifetime of mutex lock in debug iterator * include/debug/safe_iterator.h (_Safe_iterator::operator++()): Fix lifetime of lock. diff --git a/libstdc++-v3/include/debug/safe_iterator.h b/libstdc++-v3/include/debug/safe_iterator.h index 5368f3b..3f5a7f8 100644 --- a/libstdc++-v3/include/debug/safe_iterator.h +++ b/libstdc++-v3/include/debug/safe_iterator.h @@ -296,7 +296,7 @@ namespace __gnu_debug _GLIBCXX_DEBUG_VERIFY(this->_M_incrementable(), _M_message(__msg_bad_inc) ._M_iterator(*this, "this")); - __gnu_cxx::__scoped_lock(this->_M_get_mutex()); + __gnu_cxx::__scoped_lock __l(this->_M_get_mutex()); ++base(); return *this; } --k+w/mQv8wyuph6w0--