Bug 28347 - FAIL: gdb.threads/signal-sigtrap.exp: sigtrap thread 1: signal SIGTRAP reaches handler
Summary: FAIL: gdb.threads/signal-sigtrap.exp: sigtrap thread 1: signal SIGTRAP reache...
Status: RESOLVED DUPLICATE of bug 26867
Alias: None
Product: gdb
Classification: Unclassified
Component: threads (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-17 11:50 UTC by Tom de Vries
Modified: 2024-08-29 08:38 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments
patch making fail reproducible (1.38 KB, patch)
2021-09-17 11:50 UTC, Tom de Vries
Details | Diff
gdb.log (2.14 KB, text/x-log)
2021-09-17 11:50 UTC, Tom de Vries
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2021-09-17 11:50:06 UTC
Created attachment 13666 [details]
patch making fail reproducible

I ran into the following failure on x86_64-linux with target board unix/-m32/-fno-PIE/-no-pie and openSUSE Tumbleweed:
...
(gdb) PASS: gdb.threads/signal-sigtrap.exp: sigtrap thread 1: switch to sigtrap thread
signal SIGTRAP^M
Continuing with signal SIGTRAP.^M
[Thread 0xf7da2ac0 (LWP 1690) exited]^M
^M
Thread 1 "signal-sigtrap" received signal SIGTRAP, Trace/breakpoint trap.^M
0xf7fcc159 in __kernel_vsyscall ()^M
(gdb) FAIL: gdb.threads/signal-sigtrap.exp: sigtrap thread 1: signal SIGTRAP reaches handler
...

I had difficulty reproducing at first, but after playing with it for a while, I realized that what I'm looking at are the effects of doing "signal SIGTRAP" to a thread that is somewhere inside or inbetween pthread_create and pthread_join, and the FAIL happens when stopped at a point where the signal is blocked.

I modified the test-case to make the FAIL reproducible, and managed to reproduce it using native x86_64 on openSUSE Leap 15.2 (so, different kernel, libc, pointer size).
Comment 1 Tom de Vries 2021-09-17 11:50:23 UTC
Created attachment 13667 [details]
gdb.log
Comment 2 Tom de Vries 2021-09-17 12:05:56 UTC
So, what I understand that happens is:
- gdb command "signal SIGTRAP" sends the signal to the main thread using
  PTRACE_CONT
- the signal is blocked, so it becomes pending
- when the signal is unblocked, the pending signal is delivered, but because the
  inferior is ptraced, gdb is notified, and gdb does the stop/print/pass
  processing.

This seems to contradict the documentation, which states:
...
Invoking the signal command is not the same as invoking the kill utility from the shell. Sending a signal with kill causes GDB to decide what to do with the signal depending on the signal handling tables (see Signals). The signal command passes the signal directly to your program. 
...

I'm not sure whether the documentation needs to be updated, or gdb needs to be fixed (and indeed, can be fixed).
Comment 3 Tom de Vries 2024-08-29 08:38:44 UTC
Duplicate.

*** This bug has been marked as a duplicate of bug 26867 ***