From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EA85E388A432; Sun, 23 May 2021 11:54:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EA85E388A432 From: "simark at simark dot ca" To: gdb-prs@sourceware.org Subject: [Bug gdb/27899] [GNU/Linux, sparc64] GDB crashes when debugging multithreaded programs Date: Sun, 23 May 2021 11:54:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: gdb X-Bugzilla-Version: HEAD X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: simark at simark dot ca X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gdb-prs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-prs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 May 2021 11:54:19 -0000 https://sourceware.org/bugzilla/show_bug.cgi?id=3D27899 Simon Marchi changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |simark at simark dot ca --- Comment #2 from Simon Marchi --- I can confirm. Backtrace is: #0 0xffff8001017dc004 in __GI___poll (fds=3D0x100012cf730, nfds=3D4, timeout=3D) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 0x0000010000abb004 in gdb_wait_for_event (block=3D1) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:613 #2 0x0000010000ab9bbc in gdb_do_one_event () at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:237 #3 0x0000010000834d70 in gdb_readline_wrapper (prompt=3D0x100012cf620 "/home/simark/src/binutils-gdb/gdb/thread.c:1346: internal-error: void switch_to_thread(thread_info*): Assertion `thr !=3D NULL' failed.\nA problem internal to GDB has been detected,\nfurther debugging may"...) at /home/simark/src/binutils-gdb/gdb/top.c:1110 #4 0x00000100008eac48 in defaulted_query (ctlstr=3D0x10000c29670 "%s\nQuit= this debugging session? ", defchar=3D0 '\000', args=3D0x7feff97cad8) at /home/simark/src/binutils-gdb/gdb/utils.c:893 #5 0x00000100008eb010 in query (ctlstr=3D0x10000c29670 "%s\nQuit this debu= gging session? ") at /home/simark/src/binutils-gdb/gdb/utils.c:985 #6 0x00000100008e95dc in internal_vproblem (problem=3D0x10000f8b2d0 , file=3D0x10000bfca20 "/home/simark/src/binutils-gdb/gdb/thread.c", line=3D1346, fmt=3D0x10000bfc= 918 "%s: Assertion `%s' failed.", ap=3D0x7feff97cd78) at /home/simark/src/binutils-gdb/gdb/utils.c:373 #7 0x00000100008e9a68 in internal_verror (file=3D0x10000bfca20 "/home/simark/src/binutils-gdb/gdb/thread.c", line=3D1346, fmt=3D0x10000bfc= 918 "%s: Assertion `%s' failed.", ap=3D0x7feff97cd78) at /home/simark/src/binutils-gdb/gdb/utils.c:439 #8 0x0000010000ab9968 in internal_error (file=3D0x10000bfca20 "/home/simark/src/binutils-gdb/gdb/thread.c", line=3D1346, fmt=3D0x10000bfc= 918 "%s: Assertion `%s' failed.") at /home/simark/src/binutils-gdb/gdbsupport/errors.cc:55 #9 0x0000010000827f3c in switch_to_thread (thr=3D0x0) at /home/simark/src/binutils-gdb/gdb/thread.c:1346 #10 0x0000010000753444 in sparc_fetch_inferior_registers (proc_target=3D0x10000fa8cb0 , regcache=3D0x10000ff03c0, regnum=3D-1) at /home/simark/src/binutils-gdb/gdb/sparc-nat.c:175 #11 0x000001000075b908 in sparc64_linux_nat_target::fetch_registers (this=3D0x10000fa8cb0 , regcache=3D0x10000ff0= 3c0, regnum=3D-1) at /home/simark/src/binutils-gdb/gdb/sparc64-linux-nat.c:38 #12 0x00000100007fe6f4 in target_ops::fetch_registers (this=3D0x10000f7feb0 , arg0=3D0x10000ff03c0, arg1=3D-1) at /home/simark/src/binutils-gdb/gdb/target-delegates.c:496 #13 0x00000100008162a0 in target_fetch_registers (regcache=3D0x10000ff03c0, regno=3D-1) at /home/simark/src/binutils-gdb/gdb/target.c:3287 #14 0x000001000060a4bc in ps_lgetregs (ph=3D0x10001264368, lwpid=3D458727, gregset=3D0x7feff97d388) at /home/simark/src/binutils-gdb/gdb/proc-service.= c:158 #15 0xffff800103e32420 in __td_ta_lookup_th_unique (ta_arg=3D0x100012d7080, lwpid=3D, th=3D0x7feff97d7c8) at td_ta_map_lwp2thr.c:119 #16 0xffff800103e32604 in td_ta_map_lwp2thr (ta_arg=3D0x100012d7080, lwpid=3D, th=3D0x7feff97d7c8) at td_ta_map_lwp2thr.c:207 #17 0x000001000051fee8 in thread_from_lwp (stopped=3D0x100011a3650, ptid=3D= ...) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:415 #18 0x0000010000520150 in thread_db_notice_clone (parent=3D..., child=3D...= ) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:446 #19 0x00000100005068a8 in linux_handle_extended_wait (lp=3D0x10001230700, status=3D4479) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:1978 #20 0x000001000050a278 in linux_nat_filter_event (lwpid=3D458724, status=3D= 198015) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:2913 #21 0x000001000050b818 in linux_nat_wait_1 (ptid=3D..., ourstatus=3D0x7feff= 97e8d0, target_options=3D...) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:3194 #22 0x000001000050ca4c in linux_nat_target::wait (this=3D0x10000fa8cb0 , ptid=3D..., ourstatus=3D0x7feff97e8d0, target_options=3D...) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:3432 #23 0x00000100005237ec in thread_db_target::wait (this=3D0x10000f7feb0 , ptid=3D..., ourstatus=3D0x7feff97e8d0, options=3D..= .) at /home/simark/src/binutils-gdb/gdb/linux-thread-db.c:1379 #24 0x00000100007fa668 in target_wait (ptid=3D..., status=3D0x7feff97e8d0, options=3D...) at /home/simark/src/binutils-gdb/gdb/target.c:2000 #25 0x00000100004adb0c in do_target_wait_1 (inf=3D0x10001173170, ptid=3D..., status=3D0x7feff97e8d0, options=3D...) at /home/simark/src/binutils-gdb/gdb/infrun.c:3464 #26 0x00000100004add48 in operator() (__closure=3D0x7feff97e658, inf=3D0x10001173170) at /home/simark/src/binutils-gdb/gdb/infrun.c:3527 #27 0x00000100004ae15c in do_target_wait (wait_ptid=3D..., ecs=3D0x7feff97e= 8a8, options=3D...) at /home/simark/src/binutils-gdb/gdb/infrun.c:3540 #28 0x00000100004af254 in fetch_inferior_event () at /home/simark/src/binutils-gdb/gdb/infrun.c:3880 #29 0x0000010000486ef8 in inferior_event_handler (event_type=3DINF_REG_EVEN= T) at /home/simark/src/binutils-gdb/gdb/inf-loop.c:42 #30 0x000001000050ec10 in handle_target_event (error=3D0, client_data=3D0x0= ) at /home/simark/src/binutils-gdb/gdb/linux-nat.c:4060 #31 0x0000010000abaed4 in handle_file_event (file_ptr=3D0x10001259500, ready_mask=3D1) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:5= 75 #32 0x0000010000abb57c in gdb_wait_for_event (block=3D0) at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:701 #33 0x0000010000ab9ac4 in gdb_do_one_event () at /home/simark/src/binutils-gdb/gdbsupport/event-loop.cc:212 #34 0x0000010000543ee0 in start_event_loop () at /home/simark/src/binutils-gdb/gdb/main.c:348 #35 0x00000100005440f4 in captured_command_loop () at /home/simark/src/binutils-gdb/gdb/main.c:408 #36 0x00000100005466fc in captured_main (data=3D0x7feff97f168) at /home/simark/src/binutils-gdb/gdb/main.c:1242 #37 0x00000100005467a4 in gdb_main (args=3D0x7feff97f168) at /home/simark/src/binutils-gdb/gdb/main.c:1257 #38 0x00000100000c20f4 in main (argc=3D6, argv=3D0x7feff97f528) at /home/simark/src/binutils-gdb/gdb/gdb.c:32 This is cause by my commit here: gdb: set current thread in sparc_{fetch,collect}_inferior_registers (PR gdb/27147) =20=20=20 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd1e93af64a6b= 74921cca9bca8a7043855f9da10d That commit made sparc_{fetch,collect}_inferior_registers look up the thread_info for the given ptid and switch to that thread. However, as seen= in the stack trace, sparc_fetch_inferior_registers is called before a thread_i= nfo exists: we are creating a regcache while creating that thread_info. The only immediate solution I see it to directly set inferior_ptid, instead= of using switch_to_thread. --=20 You are receiving this mail because: You are on the CC list for the bug.=