public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug threads/31512] New: gdb.threads/attach-many-short-lived-threads.exp sometimes fails with "process 2689792 is already traced by process 2039527"
@ 2024-03-19 18:17 thiago.bauermann at linaro dot org
  2024-03-19 18:28 ` [Bug threads/31512] " thiago.bauermann at linaro dot org
  2024-03-19 18:54 ` thiago.bauermann at linaro dot org
  0 siblings, 2 replies; 3+ messages in thread
From: thiago.bauermann at linaro dot org @ 2024-03-19 18:17 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31512

            Bug ID: 31512
           Summary: gdb.threads/attach-many-short-lived-threads.exp
                    sometimes fails with "process 2689792 is already
                    traced by process 2039527"
           Product: gdb
           Version: HEAD
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: threads
          Assignee: unassigned at sourceware dot org
          Reporter: thiago.bauermann at linaro dot org
  Target Milestone: ---

When running gdb.threads/attach-many-short-lived-threads.exp in a loop, very
rarely an attach command can fail with:

   (gdb) attach 2039552
   Attaching to process 2039552
   Cannot attach to lwp 2689792: Operation not permitted (1), process 2689792
is already traced by process 2039527

PID 2039552 is the testcase inferior, and 2039527 is GDB. GDB didn't report any
success in attaching to the process so the message is surprising.

I was also able to reproduce by doing manually what the testcase does: running
the attach-many-short-lived-threads test program in one terminal and then
repeatedly trying to attach to it from GDB in another terminal

This is hard to reproduce though. In thousands of testcase runs, I saw it only
twice.

Probably not relevant, but I saw this on aarch64-linux running Ubuntu 22.04.3
LTS and kernel 5.4.0-131-generic.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug threads/31512] gdb.threads/attach-many-short-lived-threads.exp sometimes fails with "process 2689792 is already traced by process 2039527"
  2024-03-19 18:17 [Bug threads/31512] New: gdb.threads/attach-many-short-lived-threads.exp sometimes fails with "process 2689792 is already traced by process 2039527" thiago.bauermann at linaro dot org
@ 2024-03-19 18:28 ` thiago.bauermann at linaro dot org
  2024-03-19 18:54 ` thiago.bauermann at linaro dot org
  1 sibling, 0 replies; 3+ messages in thread
From: thiago.bauermann at linaro dot org @ 2024-03-19 18:28 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31512

--- Comment #1 from Thiago Jung Bauermann <thiago.bauermann at linaro dot org> ---
In bug #31312 where I first saw this issue, Tom Tromey gave a suggestion on how
to investigate this problem:

> Yeah, what I would suggest is maybe modifying the test case to
> invoke 'strace gdb ..' with some options to log the strace output
> to a file; then examine the file to see if gdb correctly detaches
> from all the threads it attached to.
> 
> That is, I'm wondering if there's some underlying bug that we haven't
> properly recognized -- this would account for the weirdness where
> one failed attach leaves gdb unable to attach in the future.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug threads/31512] gdb.threads/attach-many-short-lived-threads.exp sometimes fails with "process 2689792 is already traced by process 2039527"
  2024-03-19 18:17 [Bug threads/31512] New: gdb.threads/attach-many-short-lived-threads.exp sometimes fails with "process 2689792 is already traced by process 2039527" thiago.bauermann at linaro dot org
  2024-03-19 18:28 ` [Bug threads/31512] " thiago.bauermann at linaro dot org
@ 2024-03-19 18:54 ` thiago.bauermann at linaro dot org
  1 sibling, 0 replies; 3+ messages in thread
From: thiago.bauermann at linaro dot org @ 2024-03-19 18:54 UTC (permalink / raw)
  To: gdb-prs

https://sourceware.org/bugzilla/show_bug.cgi?id=31512

--- Comment #2 from Thiago Jung Bauermann <thiago.bauermann at linaro dot org> ---
Created attachment 15417
  --> https://sourceware.org/bugzilla/attachment.cgi?id=15417&action=edit
gdb.log demonstrating the problem, or perhaps a similar one.

As luck would have it, I just had this result after running the testcase in
a loop 200 times. This was on an x86_64-linux machine running Ubuntu
22.04.3 LTS with kernel 5.11.0-40-generic (not sure if it's relevant).

It isn't exactly what I reported above, but it's similar enough that
perhaps it's the same bug:

[Switching to LWP 2834993]

Thread 9 "joinable" hit Breakpoint 4, break_fn () at
/home/thiago.bauermann/src/binutils-gdb/gdb/testsuite/gdb.threads/attach-many-short-lived-threads.c:57
57      }
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 4: break at
break_fn: 2
continue
Continuing.
Couldn't get registers: No such process.
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 4: break at
break_fn: 3
Cannot access memory at address 0x55a79be03242
(gdb) FAIL: gdb.threads/attach-many-short-lived-threads.exp: iter 4: reset
timer in the inferior
print again = 1
print seconds_left
Couldn't get registers: No such process.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 4: print
seconds_left
[LWP 2834906 exited]
[LWP 2834941 exited]
print seconds_left
detach
Couldn't get registers: No such process.
(gdb) detach
[LWP 2440799 exited]
Detaching from program:
/home/thiago.bauermann/.cache/builds/gdb-native/gdb/testsuite/outputs/gdb.threads/attach-many-short-lived-threads/attach-many-short-lived-threads,
process 2440799
[Inferior 1 (process 2440799) detached]
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 4: detach
set breakpoint always-inserted off
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 4: set
breakpoint always-inserted off
delete breakpoints
Delete all breakpoints, watchpoints, tracepoints, and catchpoints? (y or n) y
(gdb) info breakpoints
No breakpoints, watchpoints, tracepoints, or catchpoints.
(gdb) attach 2440799
Attaching to program:
/home/thiago.bauermann/.cache/builds/gdb-native/gdb/testsuite/outputs/gdb.threads/attach-many-short-lived-threads/attach-many-short-lived-threads,
process 2440799
warning: process 2440799 is already traced by process 2440778process 2440799 is
a zombie - the process has already terminated
ptrace: Operation not permitted.
(gdb) PASS: gdb.threads/attach-many-short-lived-threads.exp: iter 5: attach

The reason I'm not sure it's the same problem is that this is the first
time I saw the message "Couldn't get registers: No such process.", and also
the first time I saw the message "warning: process 2440799 is already
traced by process 2440778" being followed by "process 2440799 is a zombie -
the process has already terminated".

-- 
You are receiving this mail because:
You are on the CC list for the bug.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-19 18:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-19 18:17 [Bug threads/31512] New: gdb.threads/attach-many-short-lived-threads.exp sometimes fails with "process 2689792 is already traced by process 2039527" thiago.bauermann at linaro dot org
2024-03-19 18:28 ` [Bug threads/31512] " thiago.bauermann at linaro dot org
2024-03-19 18:54 ` thiago.bauermann at linaro dot org

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).