task core: SuspensionPoint pending-cancel parity; async subtask.cancel releases its claim at park entry - #306
Merged
Merged
Conversation
…ancel releases its claim at park entry Two follow-ups from the correctness review's task-core track. #300 — runtime/src/jspi/bridge.ts. `SuspensionPoint` gets the three changes PR #302 gave `Thread.waitUntil` (definitions.py `Thread.wait_until` 361-373): `ready()` gains the `cancellable && has_pending_cancel()` disjunct (with the live "lock is free" conjunct, `Task.implicitThreadCancellable`, unconditional here because a SuspensionPoint is always a frame of the implicit thread); `resume()` runs `deliverPendingCancel` after the block so a wakeup taken through that disjunct is a cancelled resume; `cancellable` is cleared on resume. Unreachable through today's guests (the only pending-cancel producer never applies to a SuspensionPoint owner) — the point is that the two block paths no longer diverge. Both hooks are feature-detected because some parks carry a non-Task stub. Regression: suspension_point_pending_cancel_test.ts (2 arms, fail pre-fix). #295 — runtime/src/intrinsics/async_builtins.ts. The #92 determinacy park held `hasSyncWaiter` across the whole async-form park; the reference (`canon_subtask_cancel` 2455-2461) clears it before returning BLOCKED, so the claim spans only the synchronous window around `on_cancel()`. A sibling thread running during our park and calling `waitable.join` on the same subtask trapped where the reference succeeds — #92 licenses a reordering, not a new trap. The async form now clears the flag at park entry; the sync form is unchanged (its `wait_until` is inside the window). Regression: subtask_cancel_sync_waiter_window_test.ts. Closes #295. Closes #300.
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.
Round-2 follow-ups from the correctness review, task-core track. Mechanisms in the commit message.
SuspensionPointgets the threeThread.waitUntilchanges from task core: port wait_until's pending-cancel wakeup; clear Thread.cancellable on resume (review, closes #250) #302 (pending-cancel wakeup disjunct, post-block delivery, flag cleared on resume). Regression:suspension_point_pending_cancel_test.ts, 2 arms fail pre-fix.subtask.cancelclearshasSyncWaiterat scheduler/docs: async subtask.cancel determinacy park weakens built-in atomicity — record divergence + seeded regression test #92 park entry, matching the reference's claim window (definitions.py 2455-2461); the sync form is unchanged. Regression:subtask_cancel_sync_waiter_window_test.ts.Gates: full
just gatesgreen on the union with the follow-ups PR (runtime, conformance 0/0 stale, seeds, 3 shell + 6 browser lanes, smokes).Closes #295. Closes #300. Automerge armed.