From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1D9563858D28; Fri, 29 Mar 2024 20:11:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1D9563858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1711743107; bh=yG+qumw0Cr1ZfXqd6qxku5bE4jpi4ZfLu/sE5BRYouM=; h=From:To:Subject:Date:From; b=u+up5f5eZw4XRgykbvXQgd4r+SHmV5K4ddM5M+xYzoFued0+r379SPeV6QHmMd3lt ZV3iLDy+ygvuZB24z//XgwBMYnsOWzTR51/mtGTS26sAWtg/6rcPbtpC7aGykYHFE5 slfKvG7XkUqUZQVyga+ZuEmFUI4APK5frkoxMXEA= From: "ssbssa at sourceware dot org" To: gdb-prs@sourceware.org Subject: [Bug threads/31579] New: Cannot find user-level thread for LWP Date: Fri, 29 Mar 2024 20:11:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: threads X-Bugzilla-Version: 14.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ssbssa at sourceware dot org X-Bugzilla-Status: NEW 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D31579 Bug ID: 31579 Summary: Cannot find user-level thread for LWP Product: gdb Version: 14.1 Status: NEW Severity: normal Priority: P2 Component: threads Assignee: unassigned at sourceware dot org Reporter: ssbssa at sourceware dot org Target Milestone: --- With gdb-14.2 I get the following error: ``` Attaching to process 14793 [New LWP 14799] [New LWP 14800] [New LWP 14804] [New LWP 14805] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". 0x0000003ee780b68c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0 (gdb) c Continuing. Cannot find user-level thread for LWP 14805: generic error ``` The same program runs without problem with gdb-13: ``` Attaching to process 16559 [New LWP 16561] [New LWP 16562] [New LWP 16563] [New LWP 16564] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". 0x0000003ee780b68c in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0 (gdb) c Continuing. [Detaching after fork from child process 16699] [Detaching after fork from child process 16701] [Detaching after fork from child process 16705] [Detaching after fork from child process 16709] [Detaching after fork from child process 16711] [Detaching after fork from child process 16715] ``` I bisected it to this commit: https://sourceware.org/git/?p=3Dbinutils-gdb.git;a=3Dcommitdiff;h=3D6d30ada= 87b7a515a0f623687e2faadc1d4acf440 In particular, it's the proc-service.c hunk, and I got it to work again by partly reverting the commit like this: ``` diff --git a/gdb/inferior.h b/gdb/inferior.h index 712f9b3..0753c34 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -771,12 +771,12 @@ class scoped_restore_current_inferior_for_memory /* Save the current globals and switch to the given inferior and the inferior's program space. inferior_ptid is set to point to the inferior's process id (and not to any particular thread). */ - explicit scoped_restore_current_inferior_for_memory (inferior *inf) + explicit scoped_restore_current_inferior_for_memory (inferior *inf, ptid= _t ptid =3D null_ptid) : m_save_ptid (&inferior_ptid) { set_current_inferior (inf); set_current_program_space (inf->pspace); - inferior_ptid =3D ptid_t (inf->pid); + inferior_ptid =3D ptid =3D=3D null_ptid ? ptid_t (inf->pid) : ptid; } DISABLE_COPY_AND_ASSIGN (scoped_restore_current_inferior_for_memory); diff --git a/gdb/proc-service.c b/gdb/proc-service.c index f735eb0..dcb8e2b 100644 --- a/gdb/proc-service.c +++ b/gdb/proc-service.c @@ -72,7 +72,7 @@ ps_xfer_memory (const struct ps_prochandle *ph, psaddr_t addr, gdb_byte *buf, size_t len, int write) { - scoped_restore_current_inferior_for_memory save_inferior (ph->thread->in= f); + scoped_restore_current_inferior_for_memory save_inferior (ph->thread->in= f, ph->thread->ptid); CORE_ADDR core_addr =3D ps_addr_to_core_addr (addr); ``` When I set a breakpoint at ps_xfer_memory, it stops there twice for each "Detaching after fork from child process" message, and it looks like this: ``` (top-gdb) bt #0 ps_xfer_memory (ph=3D0x8f94c18, addr=3D0x3ee7a1c2a0 <__stack_user>, buf=3D0x7ffec1dc5dc0 "", len=3D8, write=3D0) at ../../gdb/proc-service.c:74 #1 0x00007f46c7add770 in _td_fetch_value () from /lib64/libthread_db.so.1 #2 0x00007f46c7adad6d in td_ta_map_lwp2thr () from /lib64/libthread_db.so.1 #3 0x00000000008c07c5 in thread_from_lwp (stopped=3D0x249d420, ptid=3D...)= at ../../gdb/linux-thread-db.c:415 #4 0x00000000008c179b in thread_db_target::wait (this=3D, ptid=3D..., ourstatus=3D0x7ffec1dc6568, options=3D...) at ../../gdb/linux-thread-db.c:1421 #5 0x0000000000a449e1 in target_wait (ptid=3D..., status=3Dstatus@entry=3D0x7ffec1dc6568, options=3D..., options@entry=3D...)= at ../../gdb/target.c:2613 #6 0x00000000008788d5 in do_target_wait_1 (inf=3Dinf@entry=3D0x2274460, pt= id=3D..., status=3Dstatus@entry=3D0x7ffec1dc6568, options=3Doptions@entry=3D...) at ../../gdb/infrun.c:3956 #7 0x0000000000889ecf in __lambda6::operator() (inf=3D0x2274460, __closure=3D) at ../../gdb/infrun.c:4015 #8 do_target_wait (options=3D..., ecs=3D0x7ffec1dc6540) at ../../gdb/infru= n.c:4034 #9 fetch_inferior_event () at ../../gdb/infrun.c:4445 #10 0x0000000000bbdf2d in gdb_wait_for_event (block=3Dblock@entry=3D0) at ../../gdbsupport/event-loop.cc:694 #11 0x0000000000bbe6d7 in gdb_do_one_event (mstimeout=3Dmstimeout@entry=3D-= 1) at ../../gdbsupport/event-loop.cc:217 #12 0x00000000008d07ca in start_event_loop () at ../../gdb/main.c:411 #13 captured_command_loop () at ../../gdb/main.c:475 #14 0x00000000008d25e5 in captured_main (data=3Ddata@entry=3D0x7ffec1dc6690= ) at ../../gdb/main.c:1348 #15 gdb_main (args=3Dargs@entry=3D0x7ffec1dc66b0) at ../../gdb/main.c:1367 #16 0x0000000000621e35 in main (argc=3D6, argv=3D0x7ffec1dc67c8) at ../../gdb/gdb.c:39 (top-gdb) p ph->thread->inf->pid $1 =3D 20298 (top-gdb) p ph->thread->ptid $2 =3D {m_pid =3D 20298, m_lwp =3D 20304, m_tid =3D 0} ``` I can't share the executable, but can try to make a reproducer if someone h= as a suggestion what it should look like. --=20 You are receiving this mail because: You are on the CC list for the bug.=