This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug c++/20020] GDB segfault on printing objects
- From: "keiths at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Wed, 02 Aug 2017 19:55:45 +0000
- Subject: [Bug c++/20020] GDB segfault on printing objects
- Auto-submitted: auto-generated
- References: <bug-20020-4717@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=20020
Keith Seitz <keiths at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |keiths at redhat dot com
--- Comment #3 from Keith Seitz <keiths at redhat dot com> ---
(In reply to Thilo Voertler from comment #1)
> Any comment would be appreciated
Thank you for chasing this down. I have investigated this a little, and I see
this hunk from commit 492d29ea is probably the culprit:
@@ -313,18 +313,21 @@ cp_print_value_fields (struct type *type, struct type
*rea
l_type,
}
else if (field_is_static (&TYPE_FIELD (type, i)))
{
- volatile struct gdb_exception ex;
struct value *v = NULL;
- TRY_CATCH (ex, RETURN_MASK_ERROR)
+ TRY
{
v = value_static_field (type, i);
}
- if (ex.reason < 0)
- fprintf_filtered (stream,
- _("<error reading variable: %s>"),
- ex.message);
+ CATCH (ex, RETURN_MASK_ERROR)
+ {
+ fprintf_filtered (stream,
+ _("<error reading variable: %s>"),
+ ex.message);
+ }
+ END_CATCH
+
cp_print_static_field (TYPE_FIELD_TYPE (type, i),
v, stream, recurse + 1,
options);
Your patch should fix that. Would you care to submit your (properly formatted)
patch (and ChangeLog) to gdb-patches@sourceware.org?
(In reply to Guillaume Morin from comment #2)
> We have started experiencing a similar crash when we switched to g++ 7.1
> with c++17 semantics. When gdb tries to print a "static constexpr", it
> triggers a "error reading variable: Missing ELF symbol" exception and then
> crashes at the same place as the original reporter. This seems to happen
> with every release at least from gdb 7.11. I also built the git master and
> could reproduce the problem as well.
This appears consistent with this bug, thank you for reporting.
> I have a simple reproducer:
>
Awesome! Thank you very much for this!
> Now run it with gdb:
I tried your test case (using gcc 7.0-20160916 (experimental) -- the gdb c++
compile branch) and did not reproduce the crash. I will try building something
newer. Can you give me the exact compiler version you are using? [g++ -v]
> If I compile the program above with the default c++ semantics(c++ 14), I get
> (gdb) print *this
> $1 = {static a = <optimized out>}
>
That appears to be another issue (which I have also investigated). I'm going to
open a new bug about this, c++/21892. Let's move the "optimized out" discussion
there.
--
You are receiving this mail because:
You are on the CC list for the bug.