Git rid of the notion of an unstable task
As noted in #2463, unstable exits are not actually necessary.
We can reap non-thread-group leaders in any order we wish.
This gets rid of the notion of an unstable exit. As a nice
side effect, we also get rid of a few places where we were
questionably busy-waiting for state changes. The key insight
is to used waitid(P_PID, tid, ..., WSTOPPED) rather than
`waitpid`. This allows us safely wait for a pthread exit
event or task exit, without risking a deadlock due to Linux's
refusal to allow the reaping of thread-group leaders with
still-alive members. Upon entering a zombie state, the above
call will return `-ECHILD`, regardless of whether or not we
are the thread group leader. As a nice side effect, this now
passes a fairly evil test that uses CLONE_CHILD_CLEARTID,
with a non-coredumping, but fatal signal. Previously, we would
just mark such exists as unstable and the futex release would
be racy. We can now record this properly. I don't have a use
case for this, but I think it at least motivates that there's
something useful to this change (other than my subjective
opinion that it's cleaner).
diff --git a/src/AutoRemoteSyscalls.cc b/src/AutoRemoteSyscalls.cc
index c2d85c5..a5e434a 100644
--- a/src/AutoRemoteSyscalls.cc
+++ b/src/AutoRemoteSyscalls.cc
@@ -230,7 +230,7 @@
}
long AutoRemoteSyscalls::syscall_base(int syscallno, Registers& callregs) {
- LOG(debug) << "syscall " << syscall_name(syscallno, t->arch());
+ LOG(debug) << "syscall " << syscall_name(syscallno, t->arch()) << " " << callregs;
if ((int)callregs.arg1() == SIGTRAP && use_singlestep_path &&
(is_sigaction_syscall(syscallno, t->arch()) ||