Repository navigation
fix: race tests for suspension ownership, and the three races they found (#47 § 4) - #53
Merged
Merged
Conversation
…und (#47) #47 § 4 asked for deterministic barriers and native cases. Each barrier runs the competing action inside the mocked JDI call that marks its gap (SuspensionRaceBarrierTest); two of them failed on the old code: - A frame tool and the dispatcher's lease: after the tool reserved the thread and found no evaluation, the dispatcher could lease it and run invoked code under the tool. lease() now waits while a frame tool reserves the thread (at most 2 s, then it is refused). - The hold check and a frame tool's retry: a set the dispatcher still processed vouched for the retry, but the dispatcher could release it before the retry read, and jdwp_set_local wrote into the frame of the thread's next stop. A retry now needs a hold only a tool ends — a published stop or a manual hold (SuspensionSession.userHoldsOn). The live case for a cancelled thread stop found the third: JDWP shows a thread that invokes from inside its event's handling as RUNNING even while it waits for a monitor, so the watchdog never looked at it. A thread shown running is now asked for its contended monitor too. Passing on the old code: a job still compiling refuses frame tools; the owner query then a new stop of the owner; a job's compilation then a replaced stop. Live: a stop-all released while its evaluation outlives the tool's wait. The live tests enable a thread-filtered request by suspending that thread only — a VM-wide resume broke evaluations in flight and made Order 1 flaky.
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.
Closes #47. § 1–3 landed in #52. This PR is § 4: the deterministic barrier tests and the remaining live cases.
Barrier tests (
SuspensionRaceBarrierTest)Each test runs the competing action inside the mocked JDI call that marks its gap, on the thread the dispatcher, the watchdog or a job would run it on. Every run therefore takes the same interleaving, and every scenario ends on the suspend counts the target would really have (
FakeSuspendModel).lease()waits while a frame tool reserves the thread (at most 2 s, then refused)jdwp_set_localwrote into the frame of the thread's next stopuserHoldsOn)unblockre-checks the ownerThere are also two more tests: a positive control showing that a published stop still vouches for a retry, and a check that a frame tool which never finishes makes the lease refuse after the wait.
Live cases (
SuspensionOwnershipLiveTest)SuspensionWatchdogTest).enableSuspended(request, thread)suspends only the request's filter thread. The VM-wide variant could invalidate the frame of an evaluation in flight ("Thread has been resumed"). That made Order 1 flaky; it failed in one run.Tests
taskset -c 0): 196 tests, 0 failures; looped 6× before the watchdog fix.SuspensionOwnershipLiveTest: 3 of 3 full-class runs green.Docs:
docs/event-pipeline.md§ 14,docs/threading-and-safety.md§ 5,docs/testing.md.