https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98818
Bug ID: 98818
Summary: [libbacktrace] Don't throw fatal error for unsupported
dwarf version
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libbacktrace
Assignee: unassigned at gcc dot gnu.org
Reporter: vries at gcc dot gnu.org
CC: ian at gcc dot gnu.org
Target Milestone: ---
I have several gcc versions installed. I use this f.i. for running gdb
testsuite with different gcc versions.
Consequently, I have libgcc 11 installed in my system, to be able to support
the latest gcc compiler.
After installing the libgcc 11 debuginfo package, gcc-go9 started to given me
problems:
...
$ ./outputs/gdb.go/handcall/handcall
fatal error: unrecognized DWARF version in .debug_info at 40
goroutine 1 [running, locked to thread]:
fatal error: unrecognized DWARF version in .debug_info at 40
panic during panic
goroutine 1 [running, locked to thread]:
fatal error: unrecognized DWARF version in .debug_info at 40
stack trace unavailable
...
The root cause for this is that libgcc's .debug_info contains dwarf5 units, and
that causes:
...
dwarf_buf_error (&unit_buf, "unrecognized DWARF version");
...
where we do:
...
static void
dwarf_buf_error (struct dwarf_buf *buf, const char *msg)
{
char b[200];
snprintf (b, sizeof b, "%s in %s at %d",
msg, buf->name, (int) (buf->buf - buf->start));
buf->error_callback (buf->data, b, 0);
}
...
which gets us to libgo's error_callback:
...
(gdb) l
161 /* Error callback. */
162
163 static void
164 error_callback (void *data __attribute__ ((unused)),
165 const char *msg, int errnum)
166 {
167 if (errnum == -1)
168 {
169 /* No debug info available. Carry on as best we can. */
170 return;
(gdb) l
171 }
172 if (errnum != 0)
173 runtime_printf ("%s errno %d\n", msg, errnum);
174 runtime_throw (msg);
175 }
...
ISTM that dwarf info that has a newer version than the libbacktrace reader
supports is not that different from missing debug info, so I wonder if we
should call the error_callback here with -1 instead.