Bug 24745 - GDB segfaults on displaying locals when missing debug information
Summary: GDB segfaults on displaying locals when missing debug information
Status: RESOLVED DUPLICATE of bug 20020
Alias: None
Product: gdb
Classification: Unclassified
Component: gdb (show other bugs)
Version: 8.3
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-06-28 11:09 UTC by nolange79
Modified: 2019-06-29 21:04 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nolange79 2019-06-28 11:09:52 UTC
Hello,

I ran into a rather bad issue, as I am remote debugging without having symbols from all libraries. gdb segfaults on some occasions when the debuginfo is missing. I am pretty much unable to debug via IDE while using the std libraries, hence the critical severity (sorry if that's not fitting).

tested on debian "buster" x64 with gdb 8.3 and gcc 8.3 aswell as gcc 9.1.

------- execute these

cat << 'EOF' > test.cpp
#include <string_view>

#pragma GCC optimize("O0")

extern "C" int main(int argc, char **pargv)
{
	std::string_view name(pargv[0]);
	return argc + name.size();
}
EOF

g++ --std=gnu++17 -O2 -g2 -o test test.cpp
gdb -nx -iex 'set auto-solib-add off'  test

------- then run those commands

b main
info locals
Comment 1 nolange79 2019-06-28 11:11:26 UTC
Commands should be:

b main
run
info locals
Comment 2 Tom Tromey 2019-06-28 12:59:14 UTC
I tried and got:

(gdb) info locals
name = {
  static npos = <error reading variable: Missing ELF symbol "std::basic_string_view<char, std::char_traits<char> >::npos".>, _M_len = 140737488346224, 
  _M_str = 0x0}


That message means this is a dup of bug #20020.

*** This bug has been marked as a duplicate of bug 20020 ***
Comment 3 nolange79 2019-06-28 13:42:33 UTC
Are you using gdb 8.3 or the master branch?
I am beginning to believe this only happens if libstdc++' pretty printers are *not* loaded.
Comment 4 Tom Tromey 2019-06-28 14:10:15 UTC
I used git master.  My build isn't picking up the pretty-printers.

Can you try a newer gdb?  That "Missing ELF symbol" comes from
the fix for 20020, which is why I think this is a dup of that.
Comment 5 nolange79 2019-06-29 21:04:39 UTC
(In reply to Tom Tromey from comment #4)
> I used git master.  My build isn't picking up the pretty-printers.
> 
> Can you try a newer gdb?  That "Missing ELF symbol" comes from
> the fix for 20020, which is why I think this is a dup of that.

Yeah, running 8.3.50.20190629 fixes the issue. I could not deduce from your comment or the 3 year old bug report where this was (supposed to be) fixed.

On my end, loading the pretty-printers probably did replace the "normal" access that triggers the bug.