From ebdd3070d3a2968327f39a66a40153ec78ead95b Mon Sep 17 00:00:00 2001 From: joyful-ii-V-I Date: Thu, 19 Nov 2026 00:23:46 -0500 Subject: [PATCH 1/4] fix(namewalk): order-free RIPWIRE_STATS walk counts, a disclosed alias depth cut, a watchdog that fails on a lost RSS sample MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CodeRabbit's six Minor findings on #693 (threads 4622779657, 4622779667, 4622779674, 4622779685, 4622779691, 4622779700), harvested once: - graph.h AliasNameWalk::elementTexts: when kMaxAliasDepth stops the walk with a queued alias whose own records were never read, DISCLOSE( depthCut, AliasDepthCap ) — counted as depth_cut= on the RIPWIRE_STATS alias_walk line; a queued name with no alias records is no cut. - graph.h AliasNameWalk::anyOpaque tests a level WHOLE before stopping on it, and addWritten/addField test every admitted declaration before the OR: arrow_walk calls=/visits= were 3 vs 2 and 2 vs 1 depending only on which file held which declaration (reproduced on d65f60c6d). - resolve.h isNamesakeBaseEdge asks every nested candidate (count_if, not any_of): probes= was 35 vs 23 with the "yes" candidate's file sorted last vs first. - test/namewalkcheck.sh: (P) permuted fixtures prove each count order-free (each pair has one arm red on d65f60c6d); (T) the depth cut and its no-records control; (E) the watchdog re-checks kill -0 after an empty or failed ps sample and, if the child still runs, kills and reaps it as KILLED=3 (sampling failure), distinct from the ceiling kill — a ps shim proves it, and a child that exits while ps fails still finishes. The old watchdog reported a failed sample as a finish with peak 0 KB after an unbounded wait. Verdicts are unchanged: every edit turns a short circuit into a full evaluation of the same OR. This repo's map is byte-identical to d65f60c6d. Co-Authored-By: Claude Opus 5.5 --- src/graph.h | 40 +++++++++++--- src/resolve.h | 7 ++- test/namewalkcheck.sh | 123 +++++++++++++++++++++++++++++++++++++----- 3 files changed, 147 insertions(+), 23 deletions(-) diff --git a/src/graph.h b/src/graph.h index 0b86fef4c..752e2f171 100644 --- a/src/graph.h +++ b/src/graph.h @@ -10366,6 +10366,18 @@ struct AliasNameWalk static constexpr int kMaxAliasDepth = 8; + // The DISCLOSE sink for elementTexts' one degrade: the depth bound reached with an alias still queued whose own records + // were never read, so an element type behind it is not collected (a member gate may then decline a call that type + // would have kept). Counted per elementTexts call as depth_cut= on the RIPWIRE_STATS alias_walk line; a queued name + // with no alias records is no cut (nothing was left unread). + struct DepthCut + { + enum class DisclosureWhy : std::uint8_t { AliasDepthCap }; + std::size_t walks = 0; + void disclose( DisclosureWhy ) noexcept { ++walks; } + }; + DepthCut depthCut; + // `name`'s alias records; empty when it is no alias (a name the table holds has at least one) std::span recordsOf( std::string_view name ) { @@ -10412,12 +10424,19 @@ struct AliasNameWalk } level.swap( nextLevel ); } + if( std::ranges::any_of( level, [ & ]( std::string_view name ) { return !recordsOf( name ).empty(); } ) ) + { + DISCLOSE( depthCut, DepthCut::DisclosureWhy::AliasDepthCap, + "elementTexts: kMaxAliasDepth (8 alias steps) reached with a queued alias unread — an element type behind it is not collected" ); + } } // a `->` through `type`: opaque when one of its alias records targets a std smart pointer or optional, or when // `nameOpaque( name, aliased )` holds for a name reached in d alias steps, d = 0..kMaxAliasDepth (one SET of names per // level: a name's own test depends only on whether its level is under the bound — at the bound an alias reads as - // unaliased — so one test per (name, level) is the OR the per-path recursion computed) + // unaliased — so one test per (name, level) is the OR the per-path recursion computed). A level is tested WHOLE before + // the walk stops on it: a level is a SET of names, so the visits= count is the sizes of the levels up to the first opaque + // one, whatever order the alias records (file order) list a level in. Stopping mid-level made it order-dependent. template bool anyOpaque( std::string_view type, const NameOpaque& nameOpaque ) { @@ -10427,14 +10446,16 @@ struct AliasNameWalk { nextLevel.clear(); seen.clear(); + bool opaque = false; for( const std::string_view name : level ) { ++arrowVisits; const std::span records = depth < kMaxAliasDepth ? recordsOf( name ) : std::span{}; - if( queueTargets( name, records ) || nameOpaque( name, !records.empty() ) ) - { - return true; - } + opaque = ( queueTargets( name, records ) || nameOpaque( name, !records.empty() ) ) || opaque; + } + if( opaque ) + { + return true; } level.swap( nextLevel ); } @@ -11947,7 +11968,8 @@ inline Graph buildGraph( const IngestResult& ing, const ScipOverlay* scip = null return; } out.types.push_back( typeName ); - out.opaqueArrow = out.opaqueArrow || ( viaArrow && arrowIsOpaque( typeName ) ); + const bool opaque = viaArrow && arrowIsOpaque( typeName ); // every admitted declaration tested: arrow_walk counts the set, not its order + out.opaqueArrow = out.opaqueArrow || opaque; }; // a field's recorded type: a std smart pointer's pointee is reached through `->` alone (`w_.reset()` on // `std::unique_ptr w_;` is the pointer's own member), and a pointee is the class itself, never a wrapper of it @@ -11958,7 +11980,8 @@ inline Graph buildGraph( const IngestResult& ing, const ScipOverlay* scip = null return; } out.types.push_back( t->type ); - out.opaqueArrow = out.opaqueArrow || ( viaArrow && !t->arrowOnly && arrowIsOpaque( t->type ) ); + const bool opaque = viaArrow && !t->arrowOnly && arrowIsOpaque( t->type ); // as addWritten: tested per declaration + out.opaqueArrow = out.opaqueArrow || opaque; }; const auto namedKey = [ & ]( NodeId from, std::string_view var ) -> const std::string& { @@ -14571,7 +14594,8 @@ inline Graph buildGraph( const IngestResult& ing, const ScipOverlay* scip = null } if( memstats::enabled() ) { - rw::emitTo( stderr, "[mem] alias_walk calls={} pushes={} elements={}\n", aliasWalk.elementCalls, aliasWalk.elementPushes, aliasWalk.elements ); + rw::emitTo( stderr, "[mem] alias_walk calls={} pushes={} elements={} depth_cut={}\n", aliasWalk.elementCalls, aliasWalk.elementPushes, aliasWalk.elements, + aliasWalk.depthCut.walks ); rw::emitTo( stderr, "[mem] arrow_walk calls={} visits={}\n", aliasWalk.arrowCalls, aliasWalk.arrowVisits ); const Narrower::GuardedWalkStats& gw = narrower.guardedWalkStats; rw::emitTo( stderr, "[mem] guarded_walk calls={} walks={} cones={} meant_asks={} meant={}\n", gw.calls, gw.walks, gw.cones, narrower.meantAsks, gw.meant ); diff --git a/src/resolve.h b/src/resolve.h index 2ea15800d..43b818848 100644 --- a/src/resolve.h +++ b/src/resolve.h @@ -7024,7 +7024,7 @@ inline std::string_view qualifierOuterName( std::string_view qualified ) noexcep struct NamesakeWalk { HashMap> ancestorsOf; - std::size_t probes = 0; // derives-from questions asked + std::size_t probes = 0; // derives-from questions asked (of every candidate: order-free) std::size_t walks = 0; // distinct outer names walked std::size_t pushes = 0; // names those walks entered std::size_t namesake = 0; // inherit edges judged namesakes @@ -7252,7 +7252,10 @@ inline bool isNamesakeBaseEdge( const IngestResult& ing, const ClassIdentity& id const std::string& nOuter = ing.symbols[ ids.enclosingClass[ n ] ].name; return n != derived && ( nOuter == outerName || walk.derives( outerName, nOuter, chaUp ) ); }; - if( std::ranges::any_of( nested->second, inScope ) ) + // every candidate is asked, not up to the first yes: the candidates come in node-id (file) order, and a short circuit + // made the RIPWIRE_STATS probes= count depend on where the matching class sat in it. The verdict is the same OR. + const auto inScopeCount = std::ranges::count_if( nested->second, inScope ); + if( inScopeCount > 0 ) { return true; } diff --git a/test/namewalkcheck.sh b/test/namewalkcheck.sh index 1d14d4b61..91c1d90a8 100755 --- a/test/namewalkcheck.sh +++ b/test/namewalkcheck.sh @@ -23,14 +23,29 @@ # (A) BOUND — the binary finishes FX and FXA under a 1 GiB RSS ceiling (a watchdog polls RSS and kills past it) with # well-formed maps. The fixed runs need tens of MB; an unfixed one passes the ceiling in about a second. # (B) COUNT — the deterministic counters (RIPWIRE_STATS=1 prints one `[mem]` stderr line per walk) equal the exact -# values the fixtures imply. FX: probes=35 (4 Walkers x 5 nested `Iterator`s, all "no", plus 3 Peers x 5, the -# fifth — Mid's, last in id order — the "yes" that stops any_of), walks=2 (one per distinct outer name: Outer, and -# Outer2 in the TRUE arm), pushes=74 (72 layer names, plus Mid and Base2), namesake=3. FXA: calls=1 pushes=112 -# elements=256. A push count is the visited-set bound: removing a set makes it ~1e9 and (A) kills the run first; +# values the fixtures imply. FX: probes=35 (4 Walkers x 5 nested `Iterator`s, all "no", plus 3 Peers x 5: every +# candidate is asked, the "yes" — Mid's — included), walks=2 (one per distinct outer name: Outer, and Outer2 in the +# TRUE arm), pushes=74 (72 layer names, plus Mid and Base2), namesake=3. FXA: calls=1 pushes=112 elements=256 +# depth_cut=0. A push count is the visited-set bound: removing a set makes it ~1e9 and (A) kills the run first; # probes/calls > 0 prove each walk is REACHED, so (A) cannot pass vacuously. # (C) TRUE ARM — three classes nested in `Outer2` (which derives from `Mid`) derive from a bare `Iterator` that `Mid` # nests: by C++ lookup that names Mid::Iterator, a namesake edge. namesake=3 proves the memo answers "derives" # exactly where the walk did. +# (P) ORDER — the counters are a function of the fixture's CONTENT, not of which file holds which line (the +# determinism contract covers RIPWIRE_STATS too; CodeRabbit on #693). FXP is FX with outer2.cpp renamed to sort +# FIRST, so Mid::Iterator is the first candidate in node-id order, not the last: a walk that stopped at the first +# "yes" asked 23 there, not 35. FXR1/FXR2: `Root` aliases `Plain` and `Ptr` (a std::shared_ptr) in two files, +# swapped between the two; a `->` through Root visits Root, Plain and Ptr (visits=3) — a walk that stopped +# mid-level visited 2 when Ptr's file came first. FXW1/FXW2: `Plain* recv;` and `Ptr recv;` in two files, swapped; +# a name-only `recv->size()` admits both, and each is tested (calls=2) — skipping the test once opaque gave 1. +# (T) DEPTH CUT — elementTexts stops at kMaxAliasDepth (8 alias steps) and DISCLOSEs a queued alias it left unread +# (depth_cut= counts the walks cut). FXD: `Root` -> C1 -> ... -> C9 = std::vector, so C8's record is +# unread: depth_cut=1, elements=0. FXN: the chain ends at C8, a struct (no alias records): nothing is left unread, +# depth_cut=0. +# (E) SAMPLING — the watchdog itself: a `ps` that fails, or answers empty, while the child still runs is a SAMPLING +# failure (KILLED=3: the child is killed and reaped and the arm FAILS), never a finish and never the ceiling kill +# (KILLED=1) the control arm needs. Run with a `ps` shim on PATH; a child that exits normally while the shim +# fails still finishes (KILLED=0, rc=0). # (D) CONTROL (RIPWIRE_NAMEWALK_CONTROL_BIN=) — the control binary on FX and on FXA is # KILLED past the same ceiling, which proves each fixture is its blow-up shape; and on FXS (FX's shape at 2 names # x 5 layers) and FXAS (FXA's at 3 names x 3 levels), small enough for the unfixed walks, the default map is @@ -125,7 +140,8 @@ gena(){ printf 'int useArrow( Root* p )\n{\n return p->size();\n}\n' >>"$dir/use.cpp" } -# capped OUT ERR cmd... — run under the RSS ceiling; sets RC, PEAK_KB, KILLED (0 finished, 1 past the ceiling, 2 wall) +# capped OUT ERR cmd... — run under the RSS ceiling; sets RC, PEAK_KB, KILLED (0 finished, 1 past the ceiling, 2 wall, +# 3 the RSS sample failed while the child ran — the ceiling was not enforced, so the run is stopped and the arm fails) capped(){ local out="$1" err="$2" pid rss st t0 shift 2 @@ -133,9 +149,15 @@ capped(){ pid=$! PEAK_KB=0; KILLED=0; t0=$SECONDS while kill -0 "$pid" 2>/dev/null; do - st="$( ps -o stat= -p "$pid" 2>/dev/null )" - case "$st" in Z*|'') break ;; esac - rss="$( ps -o rss= -p "$pid" 2>/dev/null | tr -d ' ' )"; rss="${rss:-0}" + st="$( ps -o stat= -p "$pid" 2>/dev/null )" || st='' + case "$st" in Z*) break ;; esac + rss="$( ps -o rss= -p "$pid" 2>/dev/null | tr -d ' ' )" || rss='' + if [ -z "$st" ] || ! [ "$rss" -ge 0 ] 2>/dev/null; then + # an empty or failed sample: either the child exited between kill -0 and ps (then it is gone and kill -0 now + # fails), or ps failed with the child still running — a run the watchdog cannot see, so it is not let finish + kill -0 "$pid" 2>/dev/null || break + kill -9 "$pid" 2>/dev/null; KILLED=3; break + fi [ "$rss" -gt "$PEAK_KB" ] && PEAK_KB="$rss" if [ "$rss" -gt "$CEIL_KB" ]; then kill -9 "$pid" 2>/dev/null; KILLED=1; break; fi if [ $(( SECONDS - t0 )) -gt "$WALL_S" ]; then kill -9 "$pid" 2>/dev/null; KILLED=2; break; fi @@ -143,11 +165,50 @@ capped(){ done wait "$pid" 2>/dev/null; RC=$? } +killedWhy(){ case "$1" in 0) echo finished ;; 1) echo "killed past the ceiling" ;; 2) echo "killed at the wall backstop" ;; 3) echo "RSS SAMPLING FAILED (ps), killed — the ceiling was not enforced" ;; *) echo "killed=$1" ;; esac; } + +# genchain DIR STEPS TAIL — Root -> C1 -> ... -> C; TAIL=alias makes C alias std::vector, TAIL=struct +# makes it a struct (no alias records) +genchain(){ + local dir="$1" steps="$2" tail="$3" k + mkdir -p "$dir" + { + printf '#include \n' + if [ "$tail" = alias ]; then printf 'typedef std::vector C%d;\n' "$steps"; else printf 'struct C%d { int c; };\n' "$steps"; fi + for k in $( seq $(( steps - 1 )) -1 1 ); do + printf 'typedef C%d C%d;\n' $(( k + 1 )) "$k" + done + printf 'typedef C1 Root;\n' + } >"$dir/chain.cpp" + printf 'struct Elem { int size() const { return 1; } };\n' >"$dir/elem.cpp" + printf 'int use()\n{\n Root m;\n return m[ 0 ].size();\n}\n' >"$dir/use.cpp" +} + +# genperm DIR KIND FIRST SECOND — two one-line files a.cpp (FIRST) and b.cpp (SECOND) beside the shared types and the call +genperm(){ + local dir="$1" kind="$2" + mkdir -p "$dir" + printf '#include \nstruct X { int size() const { return 1; } };\ntypedef std::shared_ptr Ptr;\nstruct Plain { int size() const { return 2; } };\n' >"$dir/types.cpp" + printf '%s\n' "$3" >"$dir/a.cpp" + printf '%s\n' "$4" >"$dir/b.cpp" + if [ "$kind" = alias ]; then + printf 'int useArrow( Root* p )\n{\n return p->size();\n}\n' >"$dir/use.cpp" + else + printf 'int g()\n{\n return recv->size();\n}\n' >"$dir/use.cpp" + fi +} FX="$TMP/fx"; gen "$FX" 6 12 FXS="$TMP/fxs"; gen "$FXS" 2 5 FXA="$TMP/fxa"; gena "$FXA" 16 7 FXAS="$TMP/fxas"; gena "$FXAS" 3 3 +FXP="$TMP/fxp"; cp -R "$FX" "$FXP"; mv "$FXP/outer2.cpp" "$FXP/a_outer2.cpp" # the "yes" candidate's file sorts first +FXD="$TMP/fxd"; genchain "$FXD" 9 alias +FXN="$TMP/fxn"; genchain "$FXN" 8 struct +genperm "$TMP/fxr1" alias 'typedef Plain Root;' 'typedef Ptr Root;' +genperm "$TMP/fxr2" alias 'typedef Ptr Root;' 'typedef Plain Root;' +genperm "$TMP/fxw1" written 'Plain* recv;' 'Ptr recv;' +genperm "$TMP/fxw2" written 'Ptr recv;' 'Plain* recv;' # ── (A) BOUND + (B) COUNT + (C) TRUE ARM ──────────────────────────────────────────────────────────────────────── # arm NAME DIR FILES COUNTER WANT @@ -157,7 +218,7 @@ arm(){ if [ "$KILLED" -eq 0 ] && [ "$RC" -eq 0 ]; then ok "(A) $name map finished under the 1 GiB ceiling (rc=0, peak ${PEAK_KB} KB)" else - no "(A) $name map did not finish under the ceiling: rc=$RC killed=$KILLED peak=${PEAK_KB} KB — a walk is unbounded again" + no "(A) $name map did not finish under the ceiling: rc=$RC, $( killedWhy "$KILLED" ), peak=${PEAK_KB} KB" fi if grep -q "files=$files " "$TMP/$name.xml" 2>/dev/null && grep -q '/dev/null || xmllint --noout "$TMP/$name.xml" 2>/dev/null; }; then @@ -173,9 +234,45 @@ arm(){ fi } arm FX "$FX" 12 cha_walk '[mem] cha_walk probes=35 walks=2 pushes=74 namesake=3' -arm FXA "$FXA" 18 alias_walk '[mem] alias_walk calls=1 pushes=112 elements=256' -line="$( grep -F '[mem] arrow_walk ' "$TMP/FXA.err" )"; want='[mem] arrow_walk calls=1 visits=113' -if [ "$line" = "$want" ]; then ok "(B) FXA counter is exact: $line"; else no "(B) FXA counter: want '$want', got '${line:-}'"; fi +arm FXA "$FXA" 18 alias_walk '[mem] alias_walk calls=1 pushes=112 elements=256 depth_cut=0' +# exact NAME ERRFILE COUNTER WANT — one more counter line from a run arm() already made +exact(){ + local line + line="$( grep -F "[mem] $3 " "$2" )" + if [ "$line" = "$4" ]; then ok "$1 counter is exact: $line"; else no "$1 counter: want '$4', got '${line:-}'"; fi +} +exact "(B) FXA" "$TMP/FXA.err" arrow_walk '[mem] arrow_walk calls=1 visits=113' + +# ── (P) ORDER + (T) DEPTH CUT ─────────────────────────────────────────────────────────────────────────────────── +arm FXP "$FXP" 12 cha_walk '[mem] cha_walk probes=35 walks=2 pushes=74 namesake=3' +arm FXR1 "$TMP/fxr1" 4 arrow_walk '[mem] arrow_walk calls=1 visits=3' +arm FXR2 "$TMP/fxr2" 4 arrow_walk '[mem] arrow_walk calls=1 visits=3' +arm FXW1 "$TMP/fxw1" 4 arrow_walk '[mem] arrow_walk calls=2 visits=2' +arm FXW2 "$TMP/fxw2" 4 arrow_walk '[mem] arrow_walk calls=2 visits=2' +arm FXD "$FXD" 3 alias_walk '[mem] alias_walk calls=1 pushes=8 elements=0 depth_cut=1' +arm FXN "$FXN" 3 alias_walk '[mem] alias_walk calls=1 pushes=8 elements=0 depth_cut=0' + +# ── (E) SAMPLING ──────────────────────────────────────────────────────────────────────────────────────────────── +mkdir -p "$TMP/psfail" "$TMP/psempty" "$TMP/psslow" +printf '#!/bin/sh\nexit 1\n' >"$TMP/psfail/ps" +printf '#!/bin/sh\nexit 0\n' >"$TMP/psempty/ps" +printf '#!/bin/sh\nsleep 1\nexit 1\n' >"$TMP/psslow/ps" +chmod +x "$TMP/psfail/ps" "$TMP/psempty/ps" "$TMP/psslow/ps" +for shim in psfail psempty; do + t0=$SECONDS + PATH="$TMP/$shim:$PATH" capped "$TMP/e_$shim.out" "$TMP/e_$shim.err" sleep 30 + if [ "$KILLED" -eq 3 ] && [ $(( SECONDS - t0 )) -lt 20 ] && ! kill -0 "$!" 2>/dev/null; then + ok "(E) a $shim sample on a running child is a sampling failure: $( killedWhy "$KILLED" ) (rc=$RC), not a finish or a ceiling kill" + else + no "(E) a $shim sample on a running child: want KILLED=3 within 20 s, got $( killedWhy "$KILLED" ) after $(( SECONDS - t0 )) s" + fi +done +PATH="$TMP/psslow:$PATH" capped "$TMP/e_slow.out" "$TMP/e_slow.err" sleep 0.1 +if [ "$KILLED" -eq 0 ] && [ "$RC" -eq 0 ]; then + ok "(E) a child that exits normally while ps fails still finishes (rc=0, $( killedWhy "$KILLED" ))" +else + no "(E) a child that exited normally while ps failed: want finished rc=0, got rc=$RC, $( killedWhy "$KILLED" )" +fi # ── (D) CONTROL ───────────────────────────────────────────────────────────────────────────────────────────────── if [ -n "$CONTROL" ]; then @@ -188,7 +285,7 @@ if [ -n "$CONTROL" ]; then if [ "$KILLED" -eq 1 ]; then ok "(D) control binary is KILLED past the 1 GiB ceiling on $name (peak ${PEAK_KB} KB): $name is the blow-up shape" else - no "(D) control binary was not killed on $name (rc=$RC killed=$KILLED peak=${PEAK_KB} KB): $name no longer separates" + no "(D) control binary was not killed past the ceiling on $name (rc=$RC, $( killedWhy "$KILLED" ), peak=${PEAK_KB} KB): $name no longer separates" fi done for pair in "FXS:$FXS" "FXAS:$FXAS"; do From 0de5970052960138d5752e89b14896882d8662e3 Mon Sep 17 00:00:00 2001 From: joyful-ii-V-I <210578314+joyful-ii-V-I@users.noreply.github.com> Date: Mon, 23 Nov 2026 19:19:26 -0500 Subject: [PATCH 2/4] test(namewalk): the watchdog tests ps's own exit status before stripping spaces from the RSS sample (CR #694) `ps -o rss= | tr -d ' ' || rss=''` tested tr's status, so a ps that printed a value and then exited nonzero was taken as a valid sample. The sample is now read alone (|| rss='' on ps itself) and stripped after. (E) gains a psrssfail shim: the stat sample succeeds, the RSS sample prints 123 and exits 1. Red on the old watchdog (finished after 30 s, KILLED=0), green on the fix (KILLED=3 at once). Co-Authored-By: Claude Opus 5.5 --- test/namewalkcheck.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/namewalkcheck.sh b/test/namewalkcheck.sh index 91c1d90a8..e0c3a15ee 100755 --- a/test/namewalkcheck.sh +++ b/test/namewalkcheck.sh @@ -42,7 +42,7 @@ # (depth_cut= counts the walks cut). FXD: `Root` -> C1 -> ... -> C9 = std::vector, so C8's record is # unread: depth_cut=1, elements=0. FXN: the chain ends at C8, a struct (no alias records): nothing is left unread, # depth_cut=0. -# (E) SAMPLING — the watchdog itself: a `ps` that fails, or answers empty, while the child still runs is a SAMPLING +# (E) SAMPLING — the watchdog itself: a `ps` that fails, answers empty, or prints a value and then fails, while the child still runs is a SAMPLING # failure (KILLED=3: the child is killed and reaped and the arm FAILS), never a finish and never the ceiling kill # (KILLED=1) the control arm needs. Run with a `ps` shim on PATH; a child that exits normally while the shim # fails still finishes (KILLED=0, rc=0). @@ -151,7 +151,8 @@ capped(){ while kill -0 "$pid" 2>/dev/null; do st="$( ps -o stat= -p "$pid" 2>/dev/null )" || st='' case "$st" in Z*) break ;; esac - rss="$( ps -o rss= -p "$pid" 2>/dev/null | tr -d ' ' )" || rss='' + rss="$( ps -o rss= -p "$pid" 2>/dev/null )" || rss='' # ps's own status, not a pipe's last stage + rss="${rss// /}" if [ -z "$st" ] || ! [ "$rss" -ge 0 ] 2>/dev/null; then # an empty or failed sample: either the child exited between kill -0 and ps (then it is gone and kill -0 now # fails), or ps failed with the child still running — a run the watchdog cannot see, so it is not let finish @@ -253,12 +254,15 @@ arm FXD "$FXD" 3 alias_walk '[mem] alias_walk calls=1 pushes=8 elements= arm FXN "$FXN" 3 alias_walk '[mem] alias_walk calls=1 pushes=8 elements=0 depth_cut=0' # ── (E) SAMPLING ──────────────────────────────────────────────────────────────────────────────────────────────── -mkdir -p "$TMP/psfail" "$TMP/psempty" "$TMP/psslow" +mkdir -p "$TMP/psfail" "$TMP/psempty" "$TMP/psslow" "$TMP/psrssfail" printf '#!/bin/sh\nexit 1\n' >"$TMP/psfail/ps" +# psrssfail: the stat sample succeeds, the RSS sample prints a number and THEN exits 1 — a value from a failed ps is +# no sample (CR #694: the old `ps | tr` tested tr's status and kept the 123) +printf '#!/bin/sh\ncase "$*" in *stat=*) echo S; exit 0 ;; esac\necho 123\nexit 1\n' >"$TMP/psrssfail/ps" printf '#!/bin/sh\nexit 0\n' >"$TMP/psempty/ps" printf '#!/bin/sh\nsleep 1\nexit 1\n' >"$TMP/psslow/ps" -chmod +x "$TMP/psfail/ps" "$TMP/psempty/ps" "$TMP/psslow/ps" -for shim in psfail psempty; do +chmod +x "$TMP/psfail/ps" "$TMP/psempty/ps" "$TMP/psslow/ps" "$TMP/psrssfail/ps" +for shim in psfail psempty psrssfail; do t0=$SECONDS PATH="$TMP/$shim:$PATH" capped "$TMP/e_$shim.out" "$TMP/e_$shim.err" sleep 30 if [ "$KILLED" -eq 3 ] && [ $(( SECONDS - t0 )) -lt 20 ] && ! kill -0 "$!" 2>/dev/null; then From a38ebcaa341ea421ee29a7d56bd9f078ce3abca5 Mon Sep 17 00:00:00 2001 From: joyful-ii-V-I <210578314+joyful-ii-V-I@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:01:24 -0500 Subject: [PATCH 3/4] docs(showcase): re-record the four seed-bearing blocks after src/graph.h moved rankGraphTeleport This PR adds 24 lines above rankGraphTeleport, so the published --at=src/graph.h:15069 seed now resolves to biasPrior and showcasecapturecheck arm (H) fails. Only the blocks whose command names a bodySeed-derived line or the derived ASan trace are re-run (--from-trace=-, --at, --callers=@, --run-trace), with the capture's own seeds, render loop and publish scrub; the seed is 15093 now. The same method on main's tree with a main binary reproduced the first three blocks byte for byte; the --run-trace block differs there only in its wall-clock duration_ms and in how its temp path was scrubbed ( in the recorded run, here). Co-Authored-By: Claude Opus 5.5 --- docs/captures/COMMANDS_showcase_2026-11-23.md | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/docs/captures/COMMANDS_showcase_2026-11-23.md b/docs/captures/COMMANDS_showcase_2026-11-23.md index 2ebb20aa8..c357c936e 100644 --- a/docs/captures/COMMANDS_showcase_2026-11-23.md +++ b/docs/captures/COMMANDS_showcase_2026-11-23.md @@ -3815,8 +3815,8 @@ Input file: AddressSanitizer:DEADLYSIGNAL ================================================================= ==41337==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000018 (pc 0x000102f4a1c8 bp 0x00016d2f1a40 sp 0x00016d2f19e0 T0) - #0 0x102f4a1c8 in rw::rankGraphTeleport(Graph const&, std::vector const&, float) src/graph.h:15069 - #1 0x102f3e884 in rw::rankGraph(Graph const&, float) src/graph.h:15112 + #0 0x102f4a1c8 in rw::rankGraphTeleport(Graph const&, std::vector const&, float) src/graph.h:15093 + #1 0x102f3e884 in rw::rankGraph(Graph const&, float) src/graph.h:15136 #2 0x102e11f30 in runDefaultMap(MainDispatch const&) src/main.cpp:1930 #3 0x102e01a44 in main src/main.cpp:4835 #4 0x1a2b3c0dc in start+0x9dc (dyld:arm64e+0x60dc) @@ -3824,25 +3824,25 @@ AddressSanitizer:DEADLYSIGNAL ````` ````` - + - - + + - + PageRank with an explicit teleport / personalization vector p (Σp = 1). The prior is name-quality-biased through biasPrior() so all rank modes share one weighting seam; the transition matrix (edgesinline RankedGraph rankGraphTeleport( const Graph& g, const std::vector<float>&am … [line truncated: 31 more bytes on this line] - + uniform-teleport PageRank (the default). A kRankFlagNotNamed unit (model.h) has no edge and a 0 prior weight, so the uniform share is over the ranked nodes: every other node's teleport is the value itinline RankedGraph rankGraph( const Graph& g, float alpha = 0.85f ) int runDefaultMap( const MainDispatch& d ) int main( int argc, char** argv ) - + & p, float alpha = 0.85f ) { PROFILE_SCOPE_DESCRIBE( "rankGraph: PageRank (power iteration)" ); @@ -4794,28 +4794,28 @@ ripwire 0.6.10-dev.260+gf284faded (dev, AppleClang 21.0.0.21000101, emit=std::pr # navigate — seeds, claims, slices, shapes -## `./build/ripwire . --at=src/graph.h:15069` +## `./build/ripwire . --at=src/graph.h:15093` *Hold a LOCATION, not a name: the enclosing-definition chain at FILE:LINE (a compiler error, a diff hunk, a stack frame), outermost -> innermost.* ````` - - + + ````` -## `./build/ripwire . --callers=@src/graph.h:15069` +## `./build/ripwire . --callers=@src/graph.h:15093` *The same seed in a SELECTOR position: @FILE:LINE resolves to the innermost enclosing definition, then --callers runs on it.* ````` - - + + - - + + @@ -5826,37 +5826,37 @@ ripwire: --no-stable is read only by --mcp/--listen (it opts out of the stable o **exit code: 4** ````` - + - + const&, float) src/graph.h:15069 - #1 0x102f3e884 in rw::rankGraph(Graph const&, float) src/graph.h:15112 + #0 0x102f4a1c8 in rw::rankGraphTeleport(Graph const&, std::vector const&, float) src/graph.h:15093 + #1 0x102f3e884 in rw::rankGraph(Graph const&, float) src/graph.h:15136 #2 0x102e11f30 in runDefaultMap(MainDispatch const&) src/main.cpp:1930 #3 0x102e01a44 in main src/main.cpp:4835 #4 0x1a2b3c0dc in start+0x9dc (dyld:arm64e+0x60dc)]]> - - - + + + - + PageRank with an explicit teleport / personalization vector p (Σp = 1). The prior is name-quality-biased through biasPrior() so all rank modes share one weighting seam; the transition matrix (edgesinline RankedGraph rankGraphTeleport( const Graph& g, const std::vector<float>&am … [line truncated: 31 more bytes on this line] - + uniform-teleport PageRank (the default). A kRankFlagNotNamed unit (model.h) has no edge and a 0 prior weight, so the uniform share is over the ranked nodes: every other node's teleport is the value itinline RankedGraph rankGraph( const Graph& g, float alpha = 0.85f ) int runDefaultMap( const MainDispatch& d ) int main( int argc, char** argv ) - + & p, float alpha = 0.85f ) -… [37 more display lines; full output is 6788 bytes on 35 raw line(s)] +… [37 more display lines; full output is 6702 bytes on 35 raw line(s)] ````` ## `./build/ripwire . --run-trace="true"` From 7345eef65dbf9c6bf4ff5b854177eb25d84c00dc Mon Sep 17 00:00:00 2001 From: joyful-ii-V-I <210578314+joyful-ii-V-I@users.noreply.github.com> Date: Mon, 23 Nov 2026 23:09:42 -0500 Subject: [PATCH 4/4] docs(commands): rebuild docs/COMMANDS.md from the re-recorded showcase seed blocks docs/docs_commands_build.py embeds the --at and --from-trace samples, so the seed move to src/graph.h:15093 reaches COMMANDS.md here (docscommandscheck arm (G)). Co-Authored-By: Claude Opus 5.5 --- docs/COMMANDS.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/COMMANDS.md b/docs/COMMANDS.md index 4a1869c41..b84a7f404 100644 --- a/docs/COMMANDS.md +++ b/docs/COMMANDS.md @@ -3510,10 +3510,10 @@ $ ./build/ripwire . --slice-depth=3 _Hold a LOCATION, not a name: the enclosing-definition chain at FILE:LINE (a compiler error, a diff hunk, a stack frame), outermost -> innermost._ ``` -$ ./build/ripwire . --at=src/graph.h:15069 +$ ./build/ripwire . --at=src/graph.h:15093 - - + + ``` @@ -4096,8 +4096,8 @@ $ ./build/ripwire . --from-trace=- AddressSanitizer:DEADLYSIGNAL ================================================================= ==41337==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000018 (pc 0x000102f4a1c8 bp 0x00016d2f1a40 sp 0x00016d2f19e0 T0) - #0 0x102f4a1c8 in rw::rankGraphTeleport(Graph const&, std::vector const&, float) src/graph.h:15069 - #1 0x102f3e884 in rw::rankGraph(Graph const&, float) src/graph.h:15112 + #0 0x102f4a1c8 in rw::rankGraphTeleport(Graph const&, std::vector const&, float) src/graph.h:15093 + #1 0x102f3e884 in rw::rankGraph(Graph const&, float) src/graph.h:15136 #2 0x102e11f30 in runDefaultMap(MainDispatch const&) src/main.cpp:1930 #3 0x102e01a44 in main src/main.cpp:4835 #4 0x1a2b3c0dc in start+0x9dc (dyld:arm64e+0x60dc)