Repository navigation
Conversation
#634: ndc_read_gen() lacked the regular-file type check ts_marker_read() (#625) already had for its own marker. A FIFO or character device at $REMEMBER_DIR/tmp/ndc-generation could hang the whole save indefinitely (no O_NONBLOCK, no timeout anywhere in this script) or stream unboundedly. Backported the same -f check: any non-regular-file at that path now reads as "unreadable" without ever attempting the cat. Proven with a FIFO test mirroring test_save_session_marker_unreadable_625.py's own extraction technique -- red (5s timeout trip) before the fix, green after. #635: the two guarded marker writes added by #625 placed 2>/dev/null AFTER the failing `>` redirection, so it suppressed nothing -- bash's own raw diagnostic ("... : Is a directory") leaked into hook-errors.log alongside the intended report_error() WARNING, duplicating it. Wrapped both writes in a `{ ...; }` group so 2>/dev/null applies to the group's own failure too (kept rather than dropped, so behaviour is identical whether or not the caller already flattened stderr). Reproduced directly against a directory marker: red (raw "Is a directory" line present) before the fix, green after, paired with a positive control that report_error() still fires. Added tests/test_ndc_read_gen_fifo_634.py and tests/test_marker_write_stderr_order_635.py, two changelog.d fragments, and a docs/windows-skip-triage.md row for each new blanket win32 skip. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
This was referenced Sep 10, 2026
Merged
5 of 6 tasks
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.
Summary
Two real code defects in
scripts/save-session.sh, both from the gate-3 release audit round.#634 --
ndc_read_gen()lacked the regular-file type check its siblingts_marker_read()(#625) already had. A FIFO or character device at$REMEMBER_DIR/tmp/ndc-generationcould hang the whole save indefinitely (no O_NONBLOCK, no timeout anywhere in this script), or stream unboundedly for a character device. Backported the same[ ! -f "$NDC_GEN_FILE" ]check: any non-regular-file at that path now reads asunreadablewithout ever attempting thecat.#635 -- the two
report_error-guarded marker writes added by #625 placed2>/dev/nullafter the failing>redirection, which only takes effect once that redirection has already succeeded. Bash's own raw diagnostic (... : Is a directory) leaked intohook-errors.logalongside the intended WARNING, duplicating it. Fixed by wrapping both writes in a{ date +%s > "$MARKER"; } 2>/dev/null || ...group -- chose to keep2>/dev/null(rather than drop it) so behaviour is identical whether or not the caller has already flattened stderr, per the brief's judgment call.Closes #634, closes #635.
Test plan
tests/test_ndc_read_gen_fifo_634.py-- red (5s timeout trip against the unfixedndc_read_gen()) before the fix, green after; three positive controls (regular file, absent file, dangling symlink) unaffected.tests/test_marker_write_stderr_order_635.py-- red (rawIs a directorydiagnostic present inhook-errors.log) before the fix, green after, paired with a positive control thatreport_error()still fires.tests/test_save_session_marker_unreadable_625.py(12 tests) still green -- no regression to the sibling save-session.sh: the same absent-vs-unreadable collapse #619 fixed for NDC_GEN_FILE is still present at COOLDOWN_MARKER and NDC_MARKER #625 fix this backports from.python3 .oss/assemble_changelog.py --check-- ok, both634.fixed.mdand635.fixed.mdvalid.bash -n scripts/save-session.sh-- syntax OK;shellcheck -xshows no new findings near either edited region.pytestsuite -- not run locally, per this repo's own CLAUDE.md ("the suite runs locally on demand, never on push" / the gate that blocks a merge is CI across three OSes and four interpreters).Two adjacent findings, not fixed here
Both of my two self-review spawns (an
Explorereviewer and theoss:auditor) independently found the same two classes of further instances of these exact defect shapes in the same file, outside what either issue named. Filing rather than fixing inline: each needs its own judgment call this branch's own brief already left to developer discretion once (wrap vs. drop2>/dev/null; guard shape for a read), and fixing all of them here would roughly double this diff.NOW_DAY_FILEread atscripts/save-session.sh:1013(NDC_DAY=$(cat "$NOW_DAY_FILE" 2>/dev/null | tr -d '[:space:]')) has the same FIFO-hang vulnerability ndc_read_gen() lacks the regular-file type check ts_marker_read() was given, so a FIFO/device at the NDC generation marker path hangs the save indefinitely #634 fixes forNDC_GEN_FILE, immediately adjacent to code this diff touched, with no type-check guard at all. Reproduced:mkfifo dayfifo; timeout 3 bash -c 'cat dayfifo 2>/dev/null | tr -d "[:space:]"'exits 124.2>/dev/null-after-a-failing->sites, unfixed by this diff:scripts/save-session.sh:397(COOLDOWN clock-skew self-heal),:879and:1303(NOW_DAY_FILEwrites),:1001(NDC clock-skew self-heal, deliberately left alone by this branch since it was outside Guarded marker writes' stderr suppression fires after the write, not before -- "2>/dev/null" on "date +%s > MARKER || ..." leaves the shell's own permission-denied line unsuppressed #635's stated scope), and a structurally different but mechanistically identicalif ... > file 2>/dev/null; thenshape at:1254. All leak bash's raw diagnostic intohook-errors.logon a directory-in-place-of-marker or permission-denied failure, the same defect Guarded marker writes' stderr suppression fires after the write, not before -- "2>/dev/null" on "date +%s > MARKER || ..." leaves the shell's own permission-denied line unsuppressed #635 fixes at the two sites it names, just without areport_error()to duplicate.Cross-platform claims
catblocking on a FIFO with no writer, POSIXmkfifo) is standard POSIX shell/libc behaviour with no platform-specific surface in either fix. Both new test modules arepytest.mark.skipif(sys.platform == "win32")-guarded (os.mkfifo()does not exist onwin32at all for ndc_read_gen() lacks the regular-file type check ts_marker_read() was given, so a FIFO/device at the NDC generation marker path hangs the save indefinitely #634; bash-subprocess dependency for Guarded marker writes' stderr suppression fires after the write, not before -- "2>/dev/null" on "date +%s > MARKER || ..." leaves the shell's own permission-denied line unsuppressed #635) and each has adocs/windows-skip-triage.mdrow.🤖 Generated with Claude Code
https://claude.ai/code/session_01P9WexZb39yUjQgJ53Zmf1c
[AI-generated]