From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id E66A93858428 for ; Fri, 5 Nov 2021 10:03:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E66A93858428 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 270181FD36; Fri, 5 Nov 2021 10:03:56 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0AFD813B97; Fri, 5 Nov 2021 10:03:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 0D+OAYwBhWFXeAAAMHmgww (envelope-from ); Fri, 05 Nov 2021 10:03:56 +0000 Subject: [gdb/build] Fix Wimplicit-exception-spec-mismatch in clang build To: Simon Marchi , Simon Marchi , gdb-patches@sourceware.org References: <20211102203434.3889269-1-simon.marchi@efficios.com> <39183fd0-d31d-feb4-9cfd-8c928b5eaf06@suse.de> <972f3e77-0788-e0e7-e524-e8617e4a4aee@polymtl.ca> From: Tom de Vries Message-ID: <915b1bef-6553-dddc-e274-384e49607dbb@suse.de> Date: Fri, 5 Nov 2021 11:03:55 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <972f3e77-0788-e0e7-e524-e8617e4a4aee@polymtl.ca> Content-Type: multipart/mixed; boundary="------------0AC2AE6635AB3962AF2FE48E" Content-Language: en-US X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Nov 2021 10:03:58 -0000 This is a multi-part message in MIME format. --------------0AC2AE6635AB3962AF2FE48E Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit [ was: Re: [PATCH] gdb/testsuite: set ASAN_OPTIONS=detect_leaks=0 while running tests ] On 11/4/21 9:04 PM, Simon Marchi wrote: > On 2021-11-03 06:24, Tom de Vries via Gdb-patches wrote: >> On 11/2/21 9:34 PM, Simon Marchi via Gdb-patches wrote: >>> We see some additional failures when running the testsuite against a GDB >>> compiled with ASan, compared to a GDB compiled without ASan. Some of >>> them are caused by the memory leak report shown by the GDB process when >>> it exits, and the fact that it makes it exit with a non-zero exit code. >>> >>> I generally try to remember to set ASAN_OPTIONS=detect_leaks=0 in my >>> environment when running the tests, but I don't always do it. I think >>> it would be nice if the testsuite did it. I don't see any use to have >>> leak detection when running the tests. That is, unless we ever have a >>> test that ensures GDB doesn't leak memory, which isn't going to happen >>> any time soon. >>> >> >> I like the idea. I also use the setting in my test scripts. >> >> FWIW, in addition, I also use "alloc_dealloc_mismatch=0", that error was >> triggered at some point. I've just done a run without this setting, and >> it didn't trigger anything. >> >> I tried to understand why, and stumbled onto >> https://sourceware.org/pipermail/gdb-patches/2021-May/178413.html , >> which seems to have been approved, but never committed. The problem >> described there, using LD_PRELOAD like so: >> ... >> $ LD_PRELOAD=/usr/lib64/libasan.so.6 ./gdb >> ... >> does reproduce for me, and applying the patch fixes it. I've done a >> build and test run, and will commit shortly. >> >> Also there a few test-cases which fail when using asan, we could >> annotate those perhaps with abort_on_error=1 or some such. > > Starting with this commit, I get these 4 errors with clang 12, in a > non-ASan build. The 2 -Wimplicit-exception-spec-mismatch can be fixed > by adding "noexcept", but I don't know about the -Wmissing-prototypes > ones. It might indicate that the prototype of the functions isn't > right, but I can't find the problem. > > Note that with Clang, I build with -std=gnu++17 in CXXFLAGS to avoid > the problem with gnulib headers in the string_view selftests. > Thanks for mentioning this, that saved me some time :) Reproduced, with clang 13. Fixed by patch below, WDYT? Thanks, - Tom --------------0AC2AE6635AB3962AF2FE48E Content-Type: text/x-patch; charset=UTF-8; name="0001-gdb-build-Fix-Wimplicit-exception-spec-mismatch-in-clang-build.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-gdb-build-Fix-Wimplicit-exception-spec-mismatch-in-clan"; filename*1="g-build.patch" [gdb/build] Fix Wimplicit-exception-spec-mismatch in clang build When building with clang 13 (and -std=gnu++17 to work around an issue in string_view-selftests.c), we run into a few Wimplicit-exception-spec-mismatch warnings: ... src/gdbsupport/new-op.cc:102:1: error: function previously declared with an \ explicit exception specification redeclared with an implicit exception \ specification [-Werror,-Wimplicit-exception-spec-mismatch] operator delete (void *p) ^ /usr/include/c++/11/new:130:6: note: previous declaration is here void operator delete(void*) _GLIBCXX_USE_NOEXCEPT ^ ... These are due to recent commit 5fff6115fea "Fix LD_PRELOAD=/usr/lib64/libasan.so.6 gdb". Fix this by adding the missing noexcept. Also fix a few Wmissing-prototypes warnings by adding the missing prototype. Build on x86_64-linux, using gcc 7.5.0 and clang 13.0.0. --- gdbsupport/new-op.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gdbsupport/new-op.cc b/gdbsupport/new-op.cc index 2f4c71457b1..ac7bc146bf3 100644 --- a/gdbsupport/new-op.cc +++ b/gdbsupport/new-op.cc @@ -99,7 +99,7 @@ operator new[] (std::size_t sz, const std::nothrow_t&) noexcept errors from AddressSanitizers. */ void -operator delete (void *p) +operator delete (void *p) noexcept { free (p); } @@ -110,14 +110,19 @@ operator delete (void *p, const std::nothrow_t&) noexcept return ::operator delete (p); } +extern void +operator delete (void *p, std::size_t) noexcept; + void operator delete (void *p, std::size_t) noexcept { return ::operator delete (p, std::nothrow); } +extern void operator delete[] (void *p) noexcept; + void -operator delete[] (void *p) +operator delete[] (void *p) noexcept { return ::operator delete (p); } @@ -128,6 +133,8 @@ operator delete[] (void *p, const std::nothrow_t&) noexcept return ::operator delete (p, std::nothrow); } +extern void operator delete[] (void *p, std::size_t) noexcept; + void operator delete[] (void *p, std::size_t) noexcept { --------------0AC2AE6635AB3962AF2FE48E--