From 36bcda7d5aae2672e72e375a691a4e9945d4e5c3 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 31 May 2024 09:47:48 +1200 Subject: [PATCH] Handle cases where the SIGSTOP to a detached tracee hasn't moved it to a group stop yet --- src/ReplaySession.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ReplaySession.cc b/src/ReplaySession.cc index 0f041270e31..40da2d5d009 100644 --- a/src/ReplaySession.cc +++ b/src/ReplaySession.cc @@ -2196,9 +2196,14 @@ void ReplaySession::reattach_tasks(ScopedFd new_tracee_socket, ScopedFd new_trac if (!t->wait()) { FATAL() << "Task " << t->tid << " killed unexpectedly"; } - if (SIGSTOP != t->status().group_stop()) { - WaitStatus failed_status = t->status(); - FATAL() << "Unexpected stop " << failed_status << " for " << t->tid; + WaitStatus status = t->status(); + // Normally the SIGSTOP from detach_tasks() will have been delivered to the tracee + // while it was detached, putting it into a group stop, so we'll see the group stop + // status here. However it is possible for the SIGSTOP to be queued but not delivered + // because the tracee hasn't been scheduled yet. In that case we might see the + // SIGSTOP signal stop here instead. + if (status.group_stop() != SIGSTOP && status.stop_sig() != SIGSTOP) { + FATAL() << "Unexpected stop " << status << " for " << t->tid; } t->clear_wait_status(); t->open_mem_fd();