[Bug c++/33480] New: [gdb, c++] Gdb hang on "whatis std::string::npos" with prettyprinter
vries at gcc dot gnu.org
sourceware-bugzilla@sourceware.org
Wed Sep 24 06:38:37 GMT 2025
https://sourceware.org/bugzilla/show_bug.cgi?id=33480
Bug ID: 33480
Summary: [gdb, c++] Gdb hang on "whatis std::string::npos" with
prettyprinter
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: c++
Assignee: unassigned at sourceware dot org
Reporter: vries at gcc dot gnu.org
Target Milestone: ---
On openSUSE Tumbleweed, the following problem was reported (
https://bugzilla.suse.com/show_bug.cgi?id=1250033 ) with the system package:
...
$ cat test.cc
#include <string>
int main()
{
std::string foo = "bar";
return foo.size();
}
$ g++ test.cc -g
$ cat gdb.in
set trace-commands on
file a.out
start
info auto-load python-scripts
ptype std::string::npos
whatis std::string::npos
$ gdb -q -batch -x gdb.in
+file a.out
+start
Temporary breakpoint 1 at 0x4021c7: file test.cc, line 5.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Temporary breakpoint 1, main () at test.cc:5
5 std::string foo = "bar";
+info auto-load python-scripts
Loaded Script
Yes /usr/share/gdb/auto-load/usr/lib64/libstdc++.so.6.0.34-gdb.py
+ptype std::string::npos
type = const unsigned long
+whatis std::string::npos
<HANG>
...
The package is compiled with lto, and has gdb 16.3 based sources.
I managed to reproduce the hang using O2 and current trunk, after adding this
to gdb.in to pick up the same pretty printers:
...
add-auto-load-safe-path /usr/share/gdb/auto-load
add-auto-load-scripts-directory /usr/share/gdb/auto-load
...
This is on Tumbleweed with gcc 15. I tried to reproduce on Leap 15.6 with gcc
14, but that didn't work.
Valgrind complained about uninitialized values, which I silenced using:
...
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 7cfb5452ad9..7e6e72b1e33 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -381,6 +381,8 @@ replace_typedefs_qualified_name (struct demangle_parse_info
*info,
newobj.type = DEMANGLE_COMPONENT_NAME;
newobj.u.s_name.s = obstack_strdup (&info->obstack, buf.string ());
newobj.u.s_name.len = buf.size ();
+ newobj.d_printing = 0;
+ newobj.d_counting = 0;
if (inspect_type (info, &newobj, finder, data))
{
char *s;
...
though it didn't fix the hang.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Gdb-prs
mailing list