Parent: #502 Related: #1032, #1033
Executed reproduction
On exact main at f26b9688f492b961c4c815ddbb72c490ca8f9117, a focused Context test begins a real concurrent mark, pauses the public runnable scheduler at zero, spawns the production typed concurrent_gc_marker, confirms its initial start is queued, and invokes finishConcurrentGCIfActive on the Context owner thread.
The bounded observer shows that the finish boundary cannot return until runnable capacity is restored:
context.test.concurrent GC marker finish exits while its start is scheduler-paused...FAIL (TestUnexpectedResult)
1 passed; 0 skipped; 1 failedfinishConcurrentGCIfActive publishes gc_marker_stop and immediately joins the marker. A marker that has not entered gcMarkerLoop cannot observe that stop flag because it is blocked inside the process-wide initial-slot queue, so the Context boundary and scheduler policy wait on one another.
Required change
- Give the per-cycle concurrent marker a typed start-cancellation handle.
- At every concurrent-GC finish boundary, cancel only a marker that is still waiting for its initial slot before joining it.
- A concurrently granted or running marker must retain the existing stop/join and synchronous finish semantics.
- Reset the per-cycle cancellation state only after the previous marker is joined.
- Preserve exact marker thread, runnable/blocked, stack, queue, and GC-cycle accounting under grant-versus-cancel races.
Definition of done
- The zero-capacity finish reproduction completes before capacity is restored.
- Canceled starts leave the concurrent mark to the existing synchronous finish path and balance all coordinator counters.
- Deterministic queued cancellation, running-marker, repeated-cycle, and grant-race tests pass normally and under unsuppressed TSan.
- Focused concurrent-GC, full unit, runtime-thread audit, and documentation gates pass.
- #502 records the landed commit and exact evidence.
Guardrails
Do not raise runnable capacity, run marking outside a scheduler slot, abandon an active concurrent cycle, poll/sleep in production, or weaken the safety-priority policy.