From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20845 invoked by alias); 23 Sep 2014 20:42:38 -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 20827 invoked by uid 89); 23 Sep 2014 20:42:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wg0-f41.google.com Received: from mail-wg0-f41.google.com (HELO mail-wg0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 23 Sep 2014 20:42:35 +0000 Received: by mail-wg0-f41.google.com with SMTP id k14so5128579wgh.12 for ; Tue, 23 Sep 2014 13:42:32 -0700 (PDT) X-Received: by 10.194.79.35 with SMTP id g3mr2590164wjx.110.1411504952743; Tue, 23 Sep 2014 13:42:32 -0700 (PDT) Received: from [10.2.116.96] (lhc-ac1.isrighthere.com. [193.93.203.40]) by mx.google.com with ESMTPSA id x6sm3830642wif.0.2014.09.23.13.42.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Sep 2014 13:42:32 -0700 (PDT) Message-ID: <5421DB37.8080307@gmail.com> Date: Tue, 23 Sep 2014 20:42:00 -0000 From: =?windows-1252?Q?Fran=E7ois_Dumont?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.1.1 MIME-Version: 1.0 To: Jonathan Wakely CC: "libstdc++@gcc.gnu.org" , gcc-patches Subject: Re: [Bug libstdc++/62313] Data race in debug iterators References: <5410BAB5.90803@gmail.com> <20140921220411.GD22778@redhat.com> In-Reply-To: <20140921220411.GD22778@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2014-09/txt/msg02036.txt.bz2 On 22/09/2014 00:04, Jonathan Wakely wrote: > On 10/09/14 22:55 +0200, François Dumont wrote: >> Hi >> >> Here is a proposal to fix this data race issue. >> >> I finally generalized bitset approach to fix it by inheriting from >> the normal iterator first and then the _Safe_iterator_base type. None >> of the libstdc++ iterator types are final so it is fine. >> Surprisingly, despite inheritance being private gcc got confused >> between _Safe_iterator_base _M_next and forward_list _M_next so I >> need to adapt some code to make usage of _Safe_iterator_base _M_next >> explicit. > > Access control in C++ is not related to visibility, name lookup still > finds private members, but it is an error to use them. Ok, tricky. > >> I also consider any operator where normal iterator is being >> modified while the safe iterator is linked to the list of iterators. >> This is necessary to make sure that thread sanatizer won't consider a >> race condition. I didn't touch to bitset::reference because list >> references are only access on bitset destruction which is clearly not >> an operation allowed to do while playing with references in another >> thread. >> >> Do you see any way to check for this problem in the testsuite ? Is >> there a thread sanitizer we could use ? > > GCC's -fsanitize=thread option, although using it in the testsuite > would need something like dg-require-tsan so the test doesn't run on > platforms where it doesn't work, or if GCC was built without > libsanitizer. > > Have you run some tests using -fsanitize=thread, even if they are not > in the testsuite? No I hadn't and try since but without success. When I build with -fsanitize=thread the produced binary just segfault at startup. It complained about using -fPIE at compilation time and -lpie at link time but even with those options it segfault. Don't know what is going wrong. Maybe Dmitry who reported the bug could give it a try. I will ask for this on the bug ticket > >> Index: include/debug/safe_iterator.h > Same renaming here please, to _Iter_base. > > Apart from those minor adjustments I think this looks good, but I'd > like to know that it has been tested with -fsanitize=thread, even if > only lightly tested. > > I fixed the vocabulary problems. Just need a slight test then. François