-
Notifications
You must be signed in to change notification settings - Fork 8
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
Sigalrm support #106
Sigalrm support #106
Conversation
…fo_t and ucontext_t) and 2) avoid concurrency issues between main thread and signal handler. This test currently fails, so I'm isolating it on its own branch.
…TIMER_VIRTUAL and ITIMER_PROF. No expected output yet. #95
src/dettraceSystemCall.cpp
Outdated
//int retVal = syscall(SYS_tgkill, t.getPid(), t.getPid(), SIGALRM); | ||
gs.log.writeToLog(Importance::info, "alarm pre-hook, requesting alarm in %u second(s)\n", t.arg1()); | ||
/* | ||
To determine how to handle alarm(), we need to know what kind of SIGALRM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gatoWololo This is the main description of how alarm
support works.
case DEFAULT_HANDLER: { | ||
// if tracee doesn't have a SIGALRM handler, we need to kill the tracee per `man 7 signal` | ||
gs.log.writeToLog(Importance::info, "tracee has default SIGALRM handler, sending SIGKILL to pid %u\n", t.getPid()); | ||
int retVal = syscall(SYS_tgkill, t.getPid(), t.getPid(), SIGKILL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gatoWololo This is where I know the tracee should get torn down (SIGALRM with default handler terminates the tracee). Sending this SIGKILL causes dettrace to throw an exception later on:
terminate called after throwing an instance of 'std::runtime_error'
what(): Ptrace failed with error: No such process
There is probably some canonical way to shut down the tracee I don't know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the tracer dies, the tracee is automatically killed, so I just exit from dettrace. That will kill everything though, which might be too much?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think we want to just kill this tracee. E.g., I saw an alarm
call from configure
, (I think) testing for the presence/behavior of the system call. Not sure what kind of signal handler it had, though, but if it had a simple alarm
call without a handler, some subprocess of configure
should terminate without tearing down the whole dettrace job.
That said, if it's hard to cleanly kill just one tracee then I don't think it's worth adding just for this corner case of alarm
, which may not even arise in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thought: maybe injecting an exit
into the tracee is the right approach here? The tracee won't exit for the right reason, which is maybe an issue, but probably not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this exit
-injection in 288757d
// struct sigaction incorrectly? Or maybe there's one definition in the | ||
// program and another one here? | ||
|
||
//if (sa.sa_flags & SA_RESETHAND) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gatoWololo Here's where I'm having some trouble reading tracee memory. The sa.sa_flags
field seems to sometimes have a garbage value of -1 (all 1's), when it should only have a few bits set. strace sees the field correctly, so there's something I'm doing wrong. Maybe the ptracer::readFromTracee()
call is incorrect?
@devietti Similarly, if the semantics of an Based on this output:
It looks like we're not actually using the |
I'll respond to your questions below. In general, I may have been too consumed by corner cases :-/. I'm not sure if these actually come up, but once I was in the midst of things it seemed easiest to add the extra functionality now instead of having to return to this later on.
Because if the SIGALRM is ignored, then
We could, but I want to make sure the tracee exits at a deterministic point.
I don't fully understand the |
We can come back to it someday post-deadline.
Sounds good. |
Here's my prototype of
alarm
support. There are two issues that I know of:alarm-nohandler
test is failing)These are also called out via commit comments.