public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Simon Marchi <simon.marchi@polymtl.ca>,
	Simon Marchi <simon.marchi@efficios.com>,
	gdb-patches@sourceware.org
Subject: [gdb/build] Fix Wimplicit-exception-spec-mismatch in clang build
Date: Fri, 5 Nov 2021 11:03:55 +0100	[thread overview]
Message-ID: <915b1bef-6553-dddc-e274-384e49607dbb@suse.de> (raw)
In-Reply-To: <972f3e77-0788-e0e7-e524-e8617e4a4aee@polymtl.ca>

[-- Attachment #1: Type: text/plain, Size: 2352 bytes --]

[ 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


[-- Attachment #2: 0001-gdb-build-Fix-Wimplicit-exception-spec-mismatch-in-clang-build.patch --]
[-- Type: text/x-patch, Size: 2038 bytes --]

[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
 {

  reply	other threads:[~2021-11-05 10:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-02 20:34 [PATCH] gdb/testsuite: set ASAN_OPTIONS=detect_leaks=0 while running tests Simon Marchi
2021-11-03 10:24 ` Tom de Vries
2021-11-03 12:28   ` Tom de Vries
2021-11-03 14:45     ` Simon Marchi
2021-11-04 11:55       ` Tom de Vries
2021-11-04 20:04   ` Simon Marchi
2021-11-05 10:03     ` Tom de Vries [this message]
2021-11-05 14:24       ` [gdb/build] Fix Wimplicit-exception-spec-mismatch in clang build Simon Marchi
2021-11-05 17:00         ` Pedro Alves
2021-11-05 17:07       ` Pedro Alves
2021-11-10 13:32         ` Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=915b1bef-6553-dddc-e274-384e49607dbb@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=simon.marchi@efficios.com \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).