Repository navigation
test(python): the stop-hang's kill line names a read, not a landing; todo rows pin the swallowed stop - #2224
Open
wanderdev0 wants to merge 1 commit into
Open
wanderdev0 wants to merge 1 commit into
wanderdev0 wants to merge 1 commit into
Conversation
…two todo rows assert the wanted backstop and message
CPython's emscripten helper zeroes the interrupt slot when it READS it and
only then asks PyErr_SetInterruptEx, which trips nothing while the script's
own SIGINT handler is ignore/default or returns (signalmodule.c:1898) - so
the CI hang's left2ms=22 named a read, never a delivery. The
python-bench-stop writer now treats the CELL's answer as success and fails
loud, slots included, when the slot was consumed and the script never
ended; the loop row's script reports, through the chunk hook, the SIGINT
handler it saw, the beacon's return, the loop's first iteration and any
unraisable it dropped, and a counter pins run()'s two own wipes.
Two { todo } rows assert the wanted behaviour when a script swallowed the
stop: the cell ends at the backstop, and neither the person's nor the
model's message names a cause the sandbox did not report ('most likely
inside a C function').
Co-Authored-By: Claude Code <noreply@anthropic.com>
This branch has not been deployed
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.
What was wrong with the instrument
The
python-bench-stopwriter treated the interrupt slot leaving 2 as the stop landing. CPython's emscripten helper (_Py_CheckEmscriptenSignals_Helperinpyodide.asm.mjs) readsPy_EmscriptenSignalBuffer[0], stores 0 back, and only then callsPyErr_SetInterruptEx(2);Modules/signalmodule.c:1898raises aKeyboardInterruptonly whenget_handler(SIGINT)is neither ignore nor default. The slot therefore leaves 2 whenever the interpreter merely looks at it, and the CI hang's line,handler=1 beacon=1 stop=1 left2ms=22 answer=0, named a read, never a delivery.Measured against the real
python-worker.tsanddist/pyodide(3 runs each, hardened cells): the default handler raisedKeyboardInterrupt3/3 in 54–69 ms;signal.signal(SIGINT, SIG_IGN)ran the cell to its end 3/3 with the slot consumed; a Python handler that returns ran the handler and then the cell to its end, 3/3. The loss is deterministic, not a race. The earlier suspicion, that a stop written during aprintcallback is lost, was disproved: a synchronous write inside the postMessage hook deliveredKeyboardInterruptin_MlTee.write.What this changes (tests only, no
src/)The writer's success is the CELL's own answer slot (
P.answer), never the slot leaving 2. A stop consumed and not raised now fails at the writer's own 15 s line with every slot printed, and the line names the case:the slot was READ at Nms and the script never endedvsthe slot still held 2 ... the interpreter never looked at itvsnever reached its beacon. This is the correctedleft2msreading, in the kill line and in the comment beside the slots.The loop row's script now reports through the chunk hook, the only place a frozen thread's account survives: the SIGINT handler it saw before the beacon (
getsig, 1 fordefault_int_handler, 2 for anything else), that the beacon print returned (prep), that the loop's first iteration ran (loop), and whether its ownsys.unraisablehooksaw the interpreter drop a tripped signal (unraisable; the default hook would write into the cell's captured stderr, which a hang never returns). A patchedAtomics.storecounts the runtime's own zeros (wipes):clearInterruptis the only writer of 0 in the product (python-worker.ts), and a completed cell is exactly 2, run()'s start and finally, which the row now asserts.Two
{ todo }rows (owner flaky-ci) assert the wanted behaviour where a script swallows the stop.tests/python-lease-offscreen.test.mjs: the cell still ends at the 1 s backstop ({ how: "killed" }, restarted, names lost), and the message does not saymost likely inside a C function.tests/python-lease.test.mjs:pyCancelText("killed")keepsnames are lostand names no cause the sandbox did not report. Both are red today for exactly that reason and go green on the repair. Neither asserts that "KeyboardInterrupt is raised under SIG_IGN"; that test can never pass.The repair is a separate PR, built by me (flaky-ci) after this lands: the offscreen document reads its own interrupt flag at kill time (still 2: the interpreter never looked, so a long step or a pure computation is the shape; zeroed and the cell did not end: the stop was consumed and not raised, so the script's own SIGINT handler swallowed it) and carries that reason in the kill answer, and
pyCancelTextplus the lease-offscreen wording say the case they know instead of "most likely inside a C function". The two todo rows are that PR's acceptance tests and neither may be weakened to pass.The CI state this does not explain
The row passes locally with the handler at the beacon measured as
default_int_handler(now asserted); the same row hung in CI at the same line. That discrepancy is still unexplained. The new slots name the state on a recurrence:getsig=2means a non-default handler was installed before the beacon, soPyErr_SetInterruptExcannot raise and the stop is genuinely unraisable;prep=0means the beacon print never returned, so the hang is inside the print/WASM bridge rather than the loop;loop=0withprep=1means the print returned and control never reached the loop;unraisable=1means a tripped signal was dropped as unraisable, the disappearing-stop case made visible;wipes=1is the expected hang (run()'s start wipe only), andwipes=2in a kill line would mean run() returned while the writer saw no answer, so the reply, not the stop, was lost.Can a dialect cell set SIGINT without asking? Measured: no
Driven through the real membership gate (the fork's
restricted.run_cell, the path the extension's inside try runs,src/python/python-dialect-run.ts, with the realdist/pyodidecore) with four shapes:signal.signal(SIGINT, SIG_IGN), a handler that returns, restoring the default handler, andsignal.getsignalalone. Every cell was refused withnot in dialect: import 'signal' (line 1). So no cell that touches SIGINT is inside the dialect, andautoApprovePython(src/agent/auto-approve.ts) answers "ask" for anything outside the dialect before it looks at any other condition, including whenautoApprovePythonis on. A model'spython_execcell that wants to swallow the stop must reach the person's approval card first; after approval it runs as full Python, wheresignal.signalworks. The unasked path to this shape is the person's own bench editor, whose script is their own code.Severity
Both Stop paths in the product already kill at 1 s: the person's Stop (
PY_INTERRUPT_KILL_MS = 1000,src/python/py-lease.ts:47) and the bench Stop (BENCH_STOP_KILL_MS = 1000,src/offscreen.ts:23), and the bench's message (BENCH_STOP_KILLED) does not blame a C function, asserted already intests/python-bench-stop-offscreen.test.mjs:103and:211. The unprotected drive is this suite's own direct call intopython-worker.ts, and its 180 s file and cell guards name the phase that hangs. What the swallowed stop really costs is the run's namespace plus a message that misnames the cause; the two todo rows pin both.🤖 Generated with Claude Code