Repository navigation
Let the TSan crash tests see the main thread's sleep on aarch64 - #874
Merged
Merged
Conversation
The TSan crash tests SIGSTOP memtier and send the SIGSEGV only when /proc/<pid>/task/<pid>/syscall shows the main thread in nanosleep or clock_nanosleep. On arm64, do_signal() calls forget_syscall() before get_signal(), where the group stop happens, so a thread stopped in a sleep reads "-1 sp pc" and the aarch64 entry in _SYS_SLEEP could never match. Every test using the helper failed after 10 s with "not seen asleep" on an aarch64 TSan build (5 of 6 tests in the file, confirmed in an Ubuntu 24.04 aarch64 container). The pc is still reported, moved back to the svc instruction so the call restarts. So read the syscall file once more just before the SIGSTOP, and on aarch64 accept a stop whose pc is 4 bytes before the pc of a sleep seen in that read. The libc check on pc stays. x86_64 keeps its number and is checked exactly as before. Fixes #843. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #843.
The TSan crash tests SIGSTOP memtier and signal the main thread only once
/proc/<pid>/task/<pid>/syscallshows it in a libcnanosleep/clock_nanosleep(#828). On arm64 the kernel clears the system call number before a group stop (do_signal()callsforget_syscall()beforeget_signal()). A thread stopped in a sleep therefore reads-1 sp pc, with pc moved back 4 bytes to thesvcinstruction so the call can restart. Theaarch64entry in_SYS_SLEEPcould never match, and the tests timed out with "not seen asleep within 10.0 s".Confirmed on aarch64 hardware (Ubuntu 24.04 container, kernel 6.8). A process blocked in sleep reads
115 … pcwhile running and-1 sp pc-4after SIGSTOP.wchandoesn't help, because a stopped thread always showsdo_signal_stop.Fix (test only,
tests/test_crash_handler_integration.py):syscallfile once just before the SIGSTOP.-1read whose pc is exactly 4 bytes before the pc of a sleep seen in that earlier read counts as that sleep.I didn't drop the aarch64 entry and fall back to a plain
kill(2), because that's what #828 replaced after it hung 14 of 60 runs.Results (aarch64 TSan build):
With the fix, the crash stack shows the signal arriving in libc
clock_nanosleep, called fromsleep. A unit check of the helper with mocked/procfiles passes all 14 cases for both architectures.Not changed: a sleep resumed after SIGCONT shows as
restart_syscalland is still refused. The issue calls this a nit, and the tests don't hit it.🤖 Generated with Claude Code
Note
Low Risk
Test-only changes to TSan crash integration helpers; no production crash-handler or runtime behavior is modified.
Overview
Fixes aarch64 TSan crash-handler integration tests that timed out because the helper could not recognize the main thread as sleeping in libc after
SIGSTOP.The TSan signaling path still stops memtier and only delivers the crash signal when the main thread is in libc
nanosleep/clock_nanosleep. The change splits syscall inspection into_main_thread_syscall()and extends_main_thread_sleeping()with an optional pre-SIGSTOPsnapshot. On arm64, when/proc/.../syscallshows syscall number-1after a group stop but the PC is 4 bytes before the PC from that snapshot, the code reuses the earlier syscall number (kernel clears it viaforget_syscall())._signal_tsan_main()now reads syscall state immediately beforeSIGSTOPand passes it through. x86_64 behavior is unchanged aside from one extra read; libc mapping checks and the sleep syscall table are the same.Reviewed by Cursor Bugbot for commit 2b28c96. Bugbot is set up for automated code reviews on this repo. Configure here.