public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "simark at simark dot ca" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug backtrace/29374] Internal-error when printing exception backtrace
Date: Sun, 24 Jul 2022 01:55:37 +0000	[thread overview]
Message-ID: <bug-29374-4717-amrHSsJ4Gq@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29374-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=29374

Simon Marchi <simark at simark dot ca> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-07-24
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |simark at simark dot ca

--- Comment #3 from Simon Marchi <simark at simark dot ca> ---
Thanks for the reproducer, I am able to reproduce.  And thanks for the
bisection.  The patch you found added some additional checks, and it looks like
it caught a pre-existing problem.

Here:

https://gitlab.com/gnutools/binutils-gdb/-/blob/6577f365ebdee7dda71cb996efa29d3714cbccd0/gdb/dwarf2/expr.c#L1027

We try to get the length of subobj_type, but it is a typedef whose actual size
hasn't been computed yet:

(top-gdb) p subobj_type.main_type.name
$1 = 0x6210001ef820 "Handler::key_type"
(top-gdb) p subobj_type.main_type.code
$2 = TYPE_CODE_TYPEDEF
(top-gdb) p subobj_type.length 
$3 = 0

If I add a check_typedef at the beginning of fetch_result, it looks like it
works:

>From 13d2d8b935f22ac2345c76a69ba009e583f9dc50 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Sat, 23 Jul 2022 21:41:55 -0400
Subject: [PATCH] patch

Change-Id: I182733ad08e34df40d8bcc47af72c482fabf4900
---
 gdb/dwarf2/expr.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gdb/dwarf2/expr.c b/gdb/dwarf2/expr.c
index 592dbe19d562..d2b7a131de33 100644
--- a/gdb/dwarf2/expr.c
+++ b/gdb/dwarf2/expr.c
@@ -930,6 +930,11 @@ dwarf_expr_context::fetch_result (struct type *type,
struct type *subobj_type,
   if (subobj_type == nullptr)
     subobj_type = type;

+  /* Ensure that, if TYPE or SUBOBJ_TYPE are typedefs, their length is filled
+     in instead of being zero.  */
+  check_typedef (type);
+  check_typedef (subobj_type);
+
   if (this->m_pieces.size () > 0)
     {
       ULONGEST bit_size = 0;

base-commit: 4bce7cdaf481901edbc5ee47d953ea7e8efb56ca
-- 
2.37.1

$./gdb -nx --data-directory=data-directory -q -batch -ex "catch throw" -ex r
-ex bt a.out 
Catchpoint 1 (throw)

This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.archlinux.org
Enable debuginfod for this session? (y or [n]) [answered N; input not from
terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/../lib/libthread_db.so.1".

Catchpoint 1 (exception thrown), 0x00007ffff7ca5e91 in __cxxabiv1::__cxa_throw
(obj=0x55555556af30, tinfo=0x555555557d20 <typeinfo for
std::runtime_error@GLIBCXX_3.4>, dest=0x7ffff7cbd370
<std::runtime_error::~runtime_error()>) at
/usr/src/debug/gcc/libstdc++-v3/libsupc++/eh_throw.cc:81
81      /usr/src/debug/gcc/libstdc++-v3/libsupc++/eh_throw.cc: No such file or
directory.
#0  0x00007ffff7ca5e91 in __cxxabiv1::__cxa_throw (obj=0x55555556af30,
tinfo=0x555555557d20 <typeinfo for std::runtime_error@GLIBCXX_3.4>,
dest=0x7ffff7cbd370 <std::runtime_error::~runtime_error()>) at
/usr/src/debug/gcc/libstdc++-v3/libsupc++/eh_throw.cc:81
#1  0x00005555555554a9 in Handler::find (this=this@entry=0x7fffffffdb20,
key=key@entry=@0x7fffffffdb1c: 0) at
/usr/include/c++/12.1.0/bits/new_allocator.h:90
#2  0x000055555555526e in Handler::operator() (key=@0x7fffffffdb1c: 0,
this=0x7fffffffdb20) at repro.cpp:14
#3  State::find (type=<optimized out>, this=0x7fffffffdb20) at repro.cpp:39
#4  main () at repro.cpp:49

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2022-07-24  1:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-17 20:31 [Bug backtrace/29374] New: " ks132 at yandex dot ru
2022-07-20 20:15 ` [Bug backtrace/29374] " ks132 at yandex dot ru
2022-07-23 13:53 ` ks132 at yandex dot ru
2022-07-24  1:55 ` simark at simark dot ca [this message]
2022-07-24  4:00 ` simark at simark dot ca
2022-07-28  2:34 ` simark at simark dot ca

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=bug-29374-4717-amrHSsJ4Gq@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /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).