Do not detach from tracee which experienced ptrace error.
Before this patch, if a thread got nuked by exit in another thread and we happened to poke it at the same time, we print "????(" thingy and detach the thread. Since we removed "detach before death" logic, this no longer matches the behavior of other threads. Before patch: [pid 1780] exit_group(1) = ? [pid 1778] ????( <unfinished ...> Process 1778 detached [pid 5860] +++ exited with 1 +++ After: [pid 17765] exit_group(1) = ? [pid 21680] ????( <unfinished ...> [pid 17791] +++ exited with 1 +++ [pid 21680] +++ exited with 1 +++ * strace (trace): Do not detach from tracee which experienced ptrace error. Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
This commit is contained in:
parent
4c1963836f
commit
f1e6903703
17
strace.c
17
strace.c
@ -2596,9 +2596,7 @@ trace()
|
||||
/* ptrace() failed in trace_syscall() with ESRCH.
|
||||
* Likely a result of process disappearing mid-flight.
|
||||
* Observed case: exit_group() terminating
|
||||
* all processes in thread group. In this case, threads
|
||||
* "disappear" in an unpredictable moment without any
|
||||
* notification to strace via wait().
|
||||
* all processes in thread group.
|
||||
*/
|
||||
if (tcp->flags & TCB_ATTACHED) {
|
||||
if (tcp_last) {
|
||||
@ -2609,11 +2607,16 @@ trace()
|
||||
tprints(" <unfinished ...>");
|
||||
printtrailer();
|
||||
}
|
||||
detach(tcp);
|
||||
/* We assume that ptrace error was caused by process death.
|
||||
* We used to detach(tcp) here, but since we no longer
|
||||
* implement "detach before death" policy/hack,
|
||||
* we can let this process to report its death to us
|
||||
* normally, via WIFEXITED or WIFSIGNALED wait status.
|
||||
*/
|
||||
} else {
|
||||
ptrace(PTRACE_KILL,
|
||||
tcp->pid, (char *) 1, SIGTERM);
|
||||
droptcb(tcp);
|
||||
/* It's our real child (and we also trace it) */
|
||||
/* my_tkill(pid, SIGKILL); - why? */
|
||||
/* droptcb(tcp); - why? */
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user