[Bug 287050] Change in PTRACE_CONTINUE causing valgrind/vgdb to no longer be able to interrupt debuggee

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 25 May 2025 09:27:15 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=287050

--- Comment #7 from Paul Floyd <pjfloyd@wanadoo.fr> ---
For the reproducer, compile both parts

clang -g -o ptrace ptrace.c -std=c23
clang -g -o sleeper sleeper.c -std=c23

Run 'sleeper'

Then run 'ptrace' with 2 arguments, first the pid of 'sleeper' and second the
address that 'sleeper' printed.

On 14.2 I get

sleeper:
DEBUG: main invoke address is 0x201850

ptrace:
./ptrace 73282 0x201850
attach to 'main' pid 73282
attach main pid PT_ATTACH pid 73282
waitstopped attach main pid before waitpid signal_expected 17
after waitpid pid 73282 p 73282 status 0x117f WIFSTOPPED 17 
calling getregs
getregs call succeeded
push bad_return return address ptrace_write_memory
calling setregs
setregs succeeded
PT_CONTINUE to invoke
waitstopped waitpid status after PTRACE_CONTINUE to invoke before waitpid
signal_expected 17
after waitpid pid 73282 p 73282 status 0x0 WIFEXITED 0 
(command prompt)

sleeper again:
 DEBUG: invoker called

On 15.0 I get

sleeper:
DEBUG: main invoke address is 0x2017c0

ptrace:
./ptrace 1244 0x2017c0
attach to 'main' pid 1244
attach main pid PT_ATTACH pid 1244
waitstopped attach main pid before waitpid signal_expected 17
after waitpid pid 1244 p 1244 status 0x117f WIFSTOPPED 17 
calling getregs
getregs call succeeded
push bad_return return address ptrace_write_memory
calling setregs
setregs succeeded
PT_CONTINUE to invoke
waitstopped waitpid status after PTRACE_CONTINUE to invoke before waitpid
signal_expected 17

There is no "after waitpid" message for ptrace and no return to the prompt.
Also no invoker message from sleeper.

-- 
You are receiving this mail because:
You are the assignee for the bug.