Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PTRACE_INTERRUPT to actually work if the tracee is not already stopped. #3923

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

khuey
Copy link
Collaborator

@khuey khuey commented Feb 17, 2025

The current code is completely untested because it will always call syscall_state.emulate_result twice and fatally assert. The ptrace_seize test does not yield between PTRACE_CONT and PTRACE_INTERRUPT, so rr will not switch to the emulated ptracee and resume execution, and the PTRACE_INTERRUPT will always find the emulated ptracee already stopped. Additionally, the test does not wait on the emulated ptracee again after interrupting it, so the following assertion about the value of status is bogus.

Fix all of that by adding the appropriate waitpid, tweaking the status assertion, duplicating the PTRACE_CONT/PTRACE_INTERRUPT sequence but with an intervening sched_yield() to force the emulated ptracee to resume, and fixing rr's PTRACE_INTERRUPT emulation to emulate_result only once and to place an emulated stop on the emulated ptracee.

…opped.

The current code is completely untested because it will always call
syscall_state.emulate_result twice and fatally assert. The ptrace_seize test
does not yield between PTRACE_CONT and PTRACE_INTERRUPT, so rr will not
switch to the emulated ptracee and resume execution, and the PTRACE_INTERRUPT
will always find the emulated ptracee already stopped. Additionally, the test
does not wait on the emulated ptracee again after interrupting it, so the
following assertion about the value of status is bogus.

Fix all of that by adding the appropriate waitpid, tweaking the status
assertion, duplicating the PTRACE_CONT/PTRACE_INTERRUPT sequence but with
an intervening sched_yield() to force the emulated ptracee to resume, and
fixing rr's PTRACE_INTERRUPT emulation to emulate_result only once and to
place an emulated stop on the emulated ptracee.
@khuey khuey requested a review from rocallahan February 17, 2025 17:41
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