Bug 17059 - GDB crashes on setting breakpoint
Summary: GDB crashes on setting breakpoint
Status: RESOLVED DUPLICATE of bug 24367
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.7
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-16 16:28 UTC by ks132
Modified: 2022-03-13 16:51 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 ks132 2014-06-16 16:28:51 UTC
Gdb crashes with stack overflow when setting breakpoint on function 'f(param*)'.
If I add param struct definition at 1st line (remove comment), breakpoint works as expected.

:~$ cat test.c 
//struct param {};

typedef struct param param;

void f(param* p) {}

int main() { f(0); return 0;}
:~$ 
:~$ 
:~$ g++ -Wall -Wextra -g test.c
test.c:5:6: warning: unused parameter ‘p’ [-Wunused-parameter]
:~$ 

:gdb$ gdb --args ./gdb --data-directory=`pwd`/data-directory -ex "b 'f(param*)'" ~/a.out 
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/asemenov/gdb-7.7.1/gdb/gdb...done.
Setting up the environment for debugging gdb.
During symbol reading, cannot get low and high bounds for subprogram DIE at 7577453.
During symbol reading, Child DIE 0x73b8db and its abstract origin 0x73a00c have different parents.
Breakpoint 1 at 0x669510: file utils.c, line 826.
Breakpoint 2 at 0x4d0a30: file ./cli/cli-cmds.c, line 218.
(top-gdb) r
Starting program: /home/asemenov/gdb-7.7.1/gdb/./gdb --data-directory=/home/asemenov/gdb-7.7.1/gdb/data-directory -ex b\ \'f\(param\*\)\' /home/asemenov/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
GNU gdb (GDB) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:

warning: python_printers.gdb: No such file or directory
Reading symbols from /home/asemenov/a.out...done.
During symbol reading, cannot get low and high bounds for subprogram DIE at 2986673.
During symbol reading, Child DIE 0x2d96cc and its abstract origin 0x2d92ea have different parents.

Program received signal SIGSEGV, Segmentation fault.
During symbol reading, incomplete CFI data; unspecified registers (e.g., rax) at 0x50eee0.
cpname_parse () at cp-name-parser.c:2077
2077	      yychar = YYLEX;
(top-gdb) bt
#0  cpname_parse () at cp-name-parser.c:2077
#1  0x0000000000511a33 in cp_demangled_name_to_comp (demangled_name=<optimized out>, errmsg=0x0) at cp-name-parser.y:2102
#2  0x0000000000678068 in cp_canonicalize_string_full (string=0xddea50 "param", finder=0x651460 <find_typedef_for_canonicalize>, data=0xb9be60 <default_ptype_flags>)
    at cp-support.c:540
#3  0x000000000065144d in print_name_maybe_canonical (name=0xddea50 "param", flags=<optimized out>, stream=0xd6b7a0) at c-typeprint.c:69
#4  0x0000000000651612 in c_type_print_base (type=0xdde9e0, stream=0xd6b7a0, show=-1, level=0, flags=0xb9be60 <default_ptype_flags>) at c-typeprint.c:862
#5  0x00000000006534d4 in c_print_type (type=0xdde9e0, varstring=0x76f610 "", stream=0xd6b7a0, show=-1, level=0, flags=0xb9be60 <default_ptype_flags>)
    at c-typeprint.c:105
#6  0x0000000000677a66 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:248
#7  0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#8  0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#9  0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#10 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#11 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#12 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#13 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#14 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#15 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#16 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#17 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#18 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#19 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#20 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#21 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#22 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#23 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#24 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#25 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#26 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#27 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#28 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#29 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#30 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#31 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#32 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#33 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#34 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#35 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#36 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#37 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#38 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#39 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#40 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#41 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#42 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#43 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
#44 0x0000000000677af3 in inspect_type (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:276
#45 0x0000000000677e49 in replace_typedefs (info=0xddc5c0, ret_comp=0xdea428, finder=0x0, data=0x0) at cp-support.c:492
---Type <return> to continue, or q <return> to quit---q
Quit
(top-gdb)
Comment 1 ks132 2014-06-17 16:26:34 UTC
Looks like this bug was introduced while working on https://sourceware.org/bugzilla/show_bug.cgi?id=12266.

I've checked out 2 git revisions: 3a93a0c2ef1629add02bfdb6efe81015819acd35 and previous one (3a93a0c2ef1629add02bfdb6efe81015819acd35^) and compiled gdb from both of them. Breakpoint test passed for 3a93a0c2ef1629add02bfdb6efe81015819acd35^ and failed for next revision (3a93a0c2ef1629add02bfdb6efe81015819acd35).
Comment 2 ks132 2014-12-31 16:49:43 UTC
This patch was proposed to fix the bug:

https://sourceware.org/ml/gdb-patches/2014-06/msg00869.html

Can anybody review and commit it?
Comment 3 Hannes Domani 2022-03-13 16:51:19 UTC
Dup.

*** This bug has been marked as a duplicate of bug 24367 ***