Skip to content

Switch to the new address space as soon as we see an exec - #4147

Open
Keno wants to merge 1 commit into
rr-debugger:masterfrom
ChronitonAI:exec-new-address-space
Open

Keno wants to merge 1 commit into
rr-debugger:masterfrom
ChronitonAI:exec-new-address-space

Conversation

@Keno

@Keno Keno commented Nov 4, 2026

Copy link
Copy Markdown
Member

[AI debug of intermittent CI failure - this has gone through a number of variations on where exactly to put this since the state changes are a bit tricky - part of a sequence of 4 patches to fix various issues with exec handling - otherwise patch/test by AI]

Between a PTRACE_EVENT_EXEC stop and post_exec(), will_schedule() could write the CPU number to the old image's rseq area, which may now be ld.so text (exec_from_other_thread-32 crashed that way in CI). Call post_exec() in record_step() as soon as the scheduler has collected an exec stop, before will_schedule(). If the stop came for the old thread-group leader, which another thread's exec killed, retire the leader there first, recording its exit if we hadn't handled it, and take the thread that exec'd instead. Tell the two apart by whether the task is in an execve: with an emulated ptracer that hasn't reaped a killed thread yet, the thread group can still have other tasks when the exec stop comes. post_exec() copes with a task that died since its stop.

Test: exec_rseq, exec_leader_exit_race, ptrace_exec_multithreaded.

Between a PTRACE_EVENT_EXEC stop and post_exec(), will_schedule() could
write the CPU number to the old image's rseq area, which may now be
ld.so text (exec_from_other_thread-32 crashed that way in CI). Call
post_exec() in record_step() as soon as the scheduler has collected an
exec stop, before will_schedule(). If the stop came for the old
thread-group leader, which another thread's exec killed, retire the
leader there first, recording its exit if we hadn't handled it, and
take the thread that exec'd instead. Tell the two apart by whether the
task is in an execve: with an emulated ptracer that hasn't reaped a
killed thread yet, the thread group can still have other tasks when
the exec stop comes. post_exec() copes with a task that died since its
stop.

Test: exec_rseq, exec_leader_exit_race, ptrace_exec_multithreaded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant