Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor grammar #1

Closed
wants to merge 1 commit into from
Closed

minor grammar #1

wants to merge 1 commit into from

Conversation

indirect
Copy link

for in → even in

for in → even in
@tmm1 tmm1 closed this in b85c3c3 Oct 10, 2013
XrXr added a commit to XrXr/stackprof that referenced this pull request Dec 10, 2024
I got a SEGV core dump with the stack trace as follows:

    #0  __pthread_kill_implementation (no_tid=0, signo=14, threadid=0) at ./nptl/pthread_kill.c:50
    tmm1#1  __pthread_kill_internal (signo=14, threadid=0) at ./nptl/pthread_kill.c:78
    tmm1#2  __GI___pthread_kill (threadid=0, signo=14) at ./nptl/pthread_kill.c:89
    tmm1#3  <signal handler called> () at /lib/x86_64-linux-gnu/libc.so.6
    tmm1#4  stackprof_start (argc=<optimized out>, argv=<optimized out>, self=<optimized out>) at stackprof.c:228
    tmm1#5  vm_call_cfunc_with_frame_
    ...

Notice that `threadid=0` in the top frame -- the SEGV comes from inside
libc as it tries to dereference `threadid`.

The signal comes from stackprof's signal handler:

    if (pthread_self() != _stackprof.target_thread) {
        pthread_kill(_stackprof.target_thread, sig);
        return;
    }

During stackprof_start(), `_stackprof.target_thread` is 0.

You can recreate the stack trace in the crash with a program that does
`pthread_kill(0, SIGALRM)`:

    #include <signal.h>

    int
    main(void)
    {
       pthread_kill(0, SIGALRM);
    }

Only set `running` after target_thread is set to avoid this crash in
case the timer expires after `settimer()` but before setting
`target_thread`.

Also, since the ordering is important here, make `running`
`volatile sig_atomic_t` to prevent the compiler from doing unwanted
reordering.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant