Skip to content

Commit

Permalink
Don't try to do remote syscalls while the task is exiting, it can't work
Browse files Browse the repository at this point in the history
  • Loading branch information
rocallahan committed Sep 30, 2023
1 parent 829533a commit 1be6241
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/AutoRemoteSyscalls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ void AutoRestoreMem::init(const void* mem, ssize_t num_bytes) {

remote.regs().set_sp(remote.regs().sp() - len);
remote.task()->set_regs(remote.regs());
if (remote.task()->is_exiting()) {
// Leave addr == nullptr
return;
}

addr = remote.regs().sp();

data.resize(len);
Expand Down Expand Up @@ -362,7 +367,7 @@ static bool ignore_signal(Task* t) {
long AutoRemoteSyscalls::syscall_base(int syscallno, Registers& callregs) {
LOG(debug) << "syscall " << syscall_name(syscallno, t->arch()) << " " << callregs;

if (t->seen_ptrace_exit_event()) {
if (t->is_exiting()) {
LOG(debug) << "Task is dying, don't try anything.";
ASSERT(t, t->stopped_or_unexpected_exit()) << "Already seen exit event";
return -ESRCH;
Expand Down
4 changes: 4 additions & 0 deletions src/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,10 @@ class Task {
*/
long fallible_ptrace(int request, remote_ptr<void> addr, void* data);

bool is_exiting() const {
return seen_ptrace_exit_event_ || was_reaped_ || in_unexpected_exit;
}

bool seen_ptrace_exit_event() const {
return seen_ptrace_exit_event_;
}
Expand Down

0 comments on commit 1be6241

Please sign in to comment.