Skip to content

Commit b16dff7

Browse files
committed
Phase 5.B c22b-mech amend-3: fix (3-gate) per testkeeper 16:03:00Z FAIL.
Two root causes diagnosed by testkeeper: - (A) script bug: EXTRA_CXXFLAGS env var not consumed by build_phoenix.sh (it expects EXTRA_CMAKE_FLAGS); -DJIT_TEST_VARIADIC_BRIDGE never reached the cmake compile flags -> shadow-emit divergence path was compiled out - (B) test-fixture inadequacy: fib(10) uses small interned ints whose refcount never decreases to zero, so MakeDecref dealloc-fallthrough generates site 600 in compiled code but never executes it at runtime. (Pythia python#376 second-order risk lands empirically.) Fix: - (A) EXTRA_CXXFLAGS -> EXTRA_CMAKE_FLAGS=" -DJIT_TEST_VARIADIC_BRIDGE=1 -DJIT_TEST_EXERCISE=1" (also forces counter into release build for diagnostic disambiguation) - (B) Replace fib(10) with stress fixture: 1000 iters of [None]*100 list alloc + dealloc; lists are not interned, deallocs reach _Py_Dealloc Diagnostic added: counter delta surfaced inline. If counter == 0 even with EXERCISE flag, FAIL-DIAGNOSTIC explicit (site re-selection for c23+). Disambiguates (3-gate) FAIL between mechanism bug and traversal inference failure. Self-attribution: third amendment cycle on c22b-mech demonstrates the recursive split from c22 -> c22a + c22b-api + c22b-mech accretes verification debt. Pythia python#380 escape-hatch concern compounds — this fix restores (3-gate) falsifiability but the FAIL surfaced only because testkeeper invoked the opt-in env-var. Without explicit invocation the mechanism degraded silently (script bug on first execution).
1 parent 9ba37f8 commit b16dff7

1 file changed

Lines changed: 35 additions & 14 deletions

File tree

‎scripts/gate_phoenix.sh‎

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,29 +162,50 @@ else
162162
fi
163163

164164
# (3-gate) JIT_TEST_VARIADIC_BRIDGE deliberate-divergence build probe.
165-
# A fully-instrumented gate would: rebuild JIT with -DJIT_TEST_VARIADIC_BRIDGE,
166-
# run force_compile fib expecting non-zero exit + grep "shadow-emit: input
167-
# count mismatch" in stderr. Re-building costs ~5min; we INFO-out unless
168-
# the env var JIT_VARIADIC_BAD_PATH_VERIFY=1 is set.
165+
# A fully-instrumented gate would: rebuild JIT with -DJIT_TEST_VARIADIC_BRIDGE
166+
# (via EXTRA_CMAKE_FLAGS — build_phoenix.sh propagates to CMAKE_CXX_FLAGS),
167+
# also -DJIT_TEST_EXERCISE so we can verify the wrapper IS reached, then run
168+
# a stress fixture that forces JIT-compiled code through _Py_Dealloc on
169+
# non-interned objects (small-int interning means fib(10) doesn't trigger
170+
# site 600 at runtime; lists/tuples of large objects do). Expected: counter
171+
# > 0 AND JIT_CHECK fires with "shadow-emit: input count mismatch".
172+
# Re-building costs ~5min; INFO-out unless JIT_VARIADIC_BAD_PATH_VERIFY=1.
169173
if [ "${JIT_VARIADIC_BAD_PATH_VERIFY:-0}" = "1" ]; then
170-
echo "(3-gate) JIT_VARIADIC_BAD_PATH_VERIFY=1 — rebuilding with -DJIT_TEST_VARIADIC_BRIDGE..." | tee -a "$RESULTS_FILE"
174+
echo "(3-gate) JIT_VARIADIC_BAD_PATH_VERIFY=1 — rebuilding with -DJIT_TEST_VARIADIC_BRIDGE -DJIT_TEST_EXERCISE..." | tee -a "$RESULTS_FILE"
171175
BAD_PATH_LOG=/tmp/jit_variadic_bad_path_$$.log
172176
pushd "$CPYTHON_ROOT" >/dev/null
173-
EXTRA_CXXFLAGS="-DJIT_TEST_VARIADIC_BRIDGE=1" bash scripts/build_phoenix.sh --pydebug --clean > "$BAD_PATH_LOG" 2>&1
177+
EXTRA_CMAKE_FLAGS=" -DJIT_TEST_VARIADIC_BRIDGE=1 -DJIT_TEST_EXERCISE=1" \
178+
bash scripts/build_phoenix.sh --pydebug --clean > "$BAD_PATH_LOG" 2>&1
174179
BAD_BUILD_RC=$?
175180
popd >/dev/null
176181
if [ "$BAD_BUILD_RC" -eq 0 ]; then
177-
BAD_RUN=$("$PYTHON" -c "import _cinderx, cinderjit
178-
def fib(n):
179-
a, b = 0, 1
180-
for _ in range(n): a, b = b, a + b
181-
return a
182-
cinderjit.force_compile(fib); fib(10)" 2>&1 || true)
182+
BAD_RUN=$("$PYTHON" -c "
183+
import _cinderx, cinderjit, ctypes
184+
# Stress fixture: non-interned object decref reliably reaches _Py_Dealloc
185+
# (site 600). fib(10) only uses interned small ints which never decref to
186+
# zero; need actual deallocs.
187+
def stress():
188+
for _ in range(1000):
189+
x = [None] * 100 # list dealloc each iter; non-interned
190+
return 1
191+
cinderjit.force_compile(stress)
192+
try:
193+
libpy = ctypes.CDLL(None)
194+
cnt = ctypes.c_int.in_dll(libpy, 'g_lir_bbb_append_invoke_call_count')
195+
pre = cnt.value
196+
except (AttributeError, ValueError):
197+
pre = -1
198+
stress()
199+
if pre >= 0:
200+
print(f'JIT_TEST_EXERCISE counter delta: {cnt.value - pre}')
201+
" 2>&1 || true)
202+
echo "$BAD_RUN" | tee -a "$RESULTS_FILE"
183203
if echo "$BAD_RUN" | grep -q "shadow-emit"; then
184204
echo "(3-gate) PASS: JIT_CHECK fired with shadow-emit message (negative-test gate-verified)" | tee -a "$RESULTS_FILE"
205+
elif echo "$BAD_RUN" | grep -qE "JIT_TEST_EXERCISE counter delta: 0$"; then
206+
echo "(3-gate) FAIL-DIAGNOSTIC: counter == 0 — stress fixture did not reach site 600. site re-selection required for c23+ (theologian fib-traversal inference falsified)" | tee -a "$RESULTS_FILE"
185207
else
186-
echo "(3-gate) FAIL: bad-path build did not fire JIT_CHECK on force_compile fib" | tee -a "$RESULTS_FILE"
187-
echo "$BAD_RUN" | tail -10 | tee -a "$RESULTS_FILE"
208+
echo "(3-gate) FAIL: bad-path build did not fire JIT_CHECK on stress fixture" | tee -a "$RESULTS_FILE"
188209
fi
189210
else
190211
echo "(3-gate) INFO: bad-path build failed (log $BAD_PATH_LOG)" | tee -a "$RESULTS_FILE"

0 commit comments

Comments
 (0)