public inbox for gdb-prs@sourceware.org help / color / mirror / Atom feed
From: "jonessyue at qnap dot com" <sourceware-bugzilla@sourceware.org> To: gdb-prs@sourceware.org Subject: [Bug gdb/31820] New: segfault when target_stack::push > t->stratum () Date: Thu, 30 May 2024 12:22:49 +0000 [thread overview] Message-ID: <bug-31820-4717@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=31820 Bug ID: 31820 Summary: segfault when target_stack::push > t->stratum () Product: gdb Version: 14.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gdb Assignee: unassigned at sourceware dot org Reporter: jonessyue at qnap dot com Target Milestone: --- cross toolchain: gcc-5.3.1, glibc-2.23, aarch64-linux-gnu-g++ When run gdb-14.2 on aarch64 cross target machine, gdb it self segfault, like this: # ./gdb Segmentation fault (core dumped) It looks like earlier gdb version works fine, test result: ----------+--------- result | gdb ver ----------+--------- segfault | gdb-14.2 segfault | gdb-10.1 pass | gdb_9.2 pass | gdb-9.1 pass | gdb-8.01 Recompile with '-O0 -g' and check backtrace, 't->stratum ()' triggered dereference null pointer 0x0 and cause segfault, not sure why the static variable 'the_dummy_target' with '_vptr.target_ops = 0x0'. Thread 1 "gdb" received signal SIGSEGV, Segmentation fault. target_stack::push (this=0xd7cb70, t=0xd04b30 <the_dummy_target>) at target.c:1206 1206 strata stratum = t->stratum (); (gdb) bt #0 target_stack::push (this=0xd7cb70, t=0xd04b30 <the_dummy_target>) at target.c:1206 #1 0x0000000000666438 in inferior::inferior (this=0xd7c9d0, pid_=<optimized out>) at inferior.c:90 #2 0x00000000006665d8 in add_inferior_silent (pid=pid@entry=0) at inferior.c:205 #3 0x0000000000667888 in initialize_inferiors () at inferior.c:1089 #4 0x0000000000805734 in gdb_init () at top.c:2327 #5 0x00000000006c5ee0 in captured_main_1 (context=context@entry=0x3fffffff638) at main.c:1036 #6 0x00000000006c6c68 in captured_main (data=data@entry=0x3fffffff638) at main.c:1314 #7 gdb_main (args=args@entry=0x3fffffff658) at main.c:1343 #8 0x000000000041ba24 in main (argc=1, argv=0x3fffffff7a8) at gdb.c:39 (gdb) p t $1 = (target_ops *) 0xd04b30 <the_dummy_target> (gdb) p *t $2 = { <refcounted_object> = { m_refcount = 1 }, members of target_ops: _vptr.target_ops = 0x0 } (gdb) p the_dummy_target $3 = { <target_ops> = { <refcounted_object> = { m_refcount = 1 }, members of target_ops: _vptr.target_ops = 0x0 }, <No data fields>} (gdb) Then startover and set a watchpoint on the static variable 'the_dummy_target', it looks like its _vptr.target_ops is 0x0 in the first place (while program loaded?) (gdb) watch the_dummy_target Hardware watchpoint 1: the_dummy_target (gdb) run <... cut dummy ...> [New LWP 5506] [New LWP 5507] [New LWP 5508] [New LWP 5510] Thread 1 "gdb" hit Hardware watchpoint 1: the_dummy_target Old value = {<target_ops> = {<refcounted_object> = {m_refcount = 0}, _vptr.target_ops = 0x0}, <No data fields>} New value = {<target_ops> = {<refcounted_object> = {m_refcount = 1}, _vptr.target_ops = 0x0}, <No data fields>} target_stack::push (this=0xd7cb70, t=0xd04b30 <the_dummy_target>) at target.c:1206 1206 strata stratum = t->stratum (); (gdb) bt #0 target_stack::push (this=0xd7cb70, t=0xd04b30 <the_dummy_target>) at target.c:1206 #1 0x0000000000666438 in inferior::inferior (this=0xd7c9d0, pid_=<optimized out>) at inferior.c:90 #2 0x00000000006665d8 in add_inferior_silent (pid=pid@entry=0) at inferior.c:205 #3 0x0000000000667888 in initialize_inferiors () at inferior.c:1089 #4 0x0000000000805734 in gdb_init () at top.c:2327 #5 0x00000000006c5ee0 in captured_main_1 (context=context@entry=0x3fffffff638) at main.c:1036 #6 0x00000000006c6c68 in captured_main (data=data@entry=0x3fffffff638) at main.c:1314 #7 gdb_main (args=args@entry=0x3fffffff658) at main.c:1343 #8 0x000000000041ba24 in main (argc=1, argv=0x3fffffff7a8) at gdb.c:39 (gdb) Since gdb-9.2 works fine so do the same breakpoint to 'target_stack::push', it shows that _vptr.target_ops is not 0x0 for 't' and 'the_dummy_target'. Not sure why latest gdb-14.2 is 0x0, will dig further. (gdb) b target_stack::push Breakpoint 1 at 0x6cec50: file ../../gdb/target.c, line 560. (gdb) run <... cut dummy ...> Breakpoint 1, target_stack::push (this=this@entry=0xaa05b8 <g_target_stack>, t=t@entry=0xa272d0 <the_dummy_target>) at ../../gdb/target.c:560 560 { (gdb) bt #0 target_stack::push (this=this@entry=0xaa05b8 <g_target_stack>, t=t@entry=0xa272d0 <the_dummy_target>) at ../../gdb/target.c:560 #1 0x00000000006cff70 in push_target (t=0xa272d0 <the_dummy_target>) at ../../gdb/target.c:579 #2 initialize_targets () at ../../gdb/target.c:3986 #3 0x00000000006dc65c in gdb_init (argv0=<optimized out>) at ../../gdb/top.c:2273 #4 0x00000000005d9428 in captured_main_1 (context=context@entry=0x3fffffff628) at ../../gdb/main.c:882 #5 0x00000000005da170 in captured_main (data=data@entry=0x3fffffff628) at ../../gdb/main.c:1192 #6 gdb_main (args=args@entry=0x3fffffff648) at ../../gdb/main.c:1217 #7 0x000000000040f3a0 in main (argc=<optimized out>, argv=<optimized out>) at ../../gdb/gdb.c:32 (gdb) l 555 556 /* See target.h. */ 557 558 void 559 target_stack::push (target_ops *t) 560 { 561 /* If there's already a target at this stratum, remove it. */ 562 strata stratum = t->stratum (); 563 564 if (m_stack[stratum] != NULL) (gdb) p t $1 = (target_ops *) 0xa272d0 <the_dummy_target> (gdb) p *t $2 = {_vptr.target_ops = 0x8d73e0 <vtable for dummy_target+16>} (gdb) p the_dummy_target $3 = {<target_ops> = {_vptr.target_ops = 0x8d73e0 <vtable for dummy_target+16>}, <No data fields>} (gdb) p the_dummy_target $4 = {<target_ops> = {_vptr.target_ops = 0x8d73e0 <vtable for dummy_target+16>}, <No data fields>} -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2024-05-30 12:22 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-30 12:22 jonessyue at qnap dot com [this message] 2024-05-30 13:36 ` [Bug gdb/31820] " tromey at sourceware dot org 2024-05-31 2:51 ` jonessyue at qnap dot com 2024-05-31 11:49 ` ssbssa at sourceware dot org 2024-06-13 6:22 ` jonessyue at qnap dot com 2024-06-13 16:16 ` tromey at sourceware dot org
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-31820-4717@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: linkBe 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).