* [RFC][gdb/threads] Fix FAIL in gdb.threads/current-lwp-dead.exp
@ 2021-10-07 14:05 Tom de Vries via Gdb-patches
0 siblings, 0 replies; only message in thread
From: Tom de Vries via Gdb-patches @ 2021-10-07 14:05 UTC (permalink / raw)
To: gdb-patches
Hi,
On openSUSE Tumbleweed, I run into:
...
(gdb) continue^M
Continuing.^M
[New Thread 0x7ffff7cc6740 (LWP 15909)]^M
[Thread 0x7ffff7cc6740 (LWP 15905) exited]^M
Cannot find user-level thread for LWP 15910: generic error^M
(gdb) FAIL: gdb.threads/current-lwp-dead.exp: \
continue to breakpoint: fn_return
...
Debugging reveals that the error is thrown during a call to thread_from_lwp
from thread_db_notice_clone.
Fix this by:
- wrapping the call in a generic try-catch,
- handling a subsequent, similar call that causes the same error in the
same way, and
- handling a segfault in thread_from_lwp by not calling it with stopped
argument == nullptr in thread_db_target::wait.
This is all symptom handling without any analysis, but it makes the
test-case pass, in the same way as it passes on openSUSE Leap 15.2:
...
(gdb) continue^M
Continuing.^M
[New Thread 0x7ffff7cc6740 (LWP 16880)]^M
[Thread 0x7ffff7cc6740 (LWP 16876) exited]^M
[New LWP 16881]^M
[Thread 0x7ffff7cc6740 (LWP 16880) exited]^M
[Switching to LWP 16881]^M
Cannot remove breakpoints because program is no longer writable.^M
Further execution is probably impossible.^M
^M
Thread 3 hit Breakpoint 2, fn_return (unused=<error reading variable: \
Cannot access memory at address 0x407298>) at current-lwp-dead.c:45^M
45 return 0; /* at-fn_return */^M
(gdb) PASS: gdb.threads/current-lwp-dead.exp: \
continue to breakpoint: fn_return
...
Tested gdb.threads/*.exp on x86_64-linux, no regressions.
Any comments?
Thanks,
- Tom
[gdb/threads] Fix FAIL in gdb.threads/current-lwp-dead.exp
---
gdb/linux-thread-db.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c
index 54e68ccd0d7..e65dce96efe 100644
--- a/gdb/linux-thread-db.c
+++ b/gdb/linux-thread-db.c
@@ -441,11 +441,24 @@ thread_db_notice_clone (ptid_t parent, ptid_t child)
thread_info *stopped = find_thread_ptid (linux_target, parent);
- thread_from_lwp (stopped, child);
+ try
+ {
+ thread_from_lwp (stopped, child);
+ }
+ catch (...)
+ {
+ }
/* If we do not know about the main thread's pthread info yet, this
would be a good time to find it. */
- thread_from_lwp (stopped, parent);
+ try
+ {
+ thread_from_lwp (stopped, parent);
+ }
+ catch (...)
+ {
+ }
+
return 1;
}
@@ -1424,7 +1437,9 @@ thread_db_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
return ptid;
/* Fill in the thread's user-level thread id and status. */
- thread_from_lwp (find_thread_ptid (beneath, ptid), ptid);
+ thread_info *stopped = find_thread_ptid (beneath, ptid);
+ if (stopped != nullptr)
+ thread_from_lwp (stopped, ptid);
return ptid;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-10-07 14:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-07 14:05 [RFC][gdb/threads] Fix FAIL in gdb.threads/current-lwp-dead.exp Tom de Vries via Gdb-patches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox