Wrong stack pointer in signal handler
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 10.7k
- Forks
- 662
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 2
Description
Consider this code:
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
static void handler (int signum)
{
printf ("handler sp = %p\n", __builtin_frame_address (0));
}
int main ()
{
printf ("sp = %p\n", __builtin_frame_address (0));
signal (SIGUSR1, handler);
kill (getpid (), SIGUSR1);
return 0;
}
When running on bare x86_64 GNU/Linux, I see:
sp = 0x7fff5c116230
handler sp = 0x7fff5c115b70
However, under rr, I get:
$ rr record /tmp/a.out
rr: Saving execution to trace directory `/home/ludo/.local/share/rr/a.out-4'.
sp = 0x7ffd59dc9c60
handler sp = 0x681ff770
The "weird" %sp is problematic when debugging applications using the BDW garbage collector (libgc). For stop-the-world garbage collections, libgc sends a signal to the process and stores the receiving thread's stack pointer and later, from another thread, scans that stack starting from that thread's recorded stack pointer in GC_thread.stop_info.stack_ptr.
What would you suggest to work around this issue?
Thanks,
Ludo'.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the discrepancy with the supplied C program under bare Linux and rr record, comparing the signal-handler frame address with the normal process value. Read the linked BDWGC pthread_stop_world.c locations around lines 333 and 697 to understand the required stack-pointer behavior. Done means a documented, reliable workaround for libgc or a confirmed rr fix path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, cpp, linux
- Domain
- devtools, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100