Skip to content

fix: seed session-driver globals with sys/gc/fuzzer_rng - #884

Merged
devdanzin merged 1 commit into
mainfrom
fix/session-driver-seed-globals
Jul 1, 2026
Merged

devdanzin merged 1 commit into
mainfrom
fix/session-driver-seed-globals

Conversation

@devdanzin

Copy link
Copy Markdown
Owner

Summary

Found by inspecting a real --session-fuzz run (jit_run10) that ran the latest code (commit 37e1c29) yet showed 2,591 NameError: name 'sys' is not defined (99.8% of ignored-crashes).

Root cause: session fuzzing runs corpus files through lafleur.driver in a shared globals dict. Corpus files are stored core-only (no import sys), so session parents/polluters — which run before the boilerplate-carrying child in [parent, child] / [polluters..., parent, child] sessions — raise NameError on their first line (the [fN] marker print(..., file=sys.stderr)). The driver seeded shared_globals with only __name__/__builtins__. Only ~15% child-only "solo" sessions were unaffected.

The earlier boilerplate fixes (#867/#878) only covered the normal per-script path; the driver is a separate execution path.

Fix: seed shared_globals with the runtime deps the stripped boilerplate supplies — sys, gc, collect, random, and a default fuzzer_rng. The child's own boilerplate still overwrites fuzzer_rng with its seeded RNG when it runs.

Verification

Direct repro on jit_run10's corpus, before vs after:

# before: [DRIVER:ERROR] .../1.py: NameError: name 'sys' is not defined
# after:  [DRIVER:START] .../1.py ... [DRIVER:STATS] {"status": "success", "jit_available": true, ...}

8/8 sampled corpus files: NameError:sys count 8 → 0.

Test plan

  • New test_run_session_seeds_boilerplate_globals — a core-only script using sys/gc/collect/fuzzer_rng runs to status: success with no NameError.
  • Full suite 2170 passed; mypy lafleur clean; ruff clean.

Closes #883

🤖 Generated with Claude Code

Session fuzzing (--session-fuzz) runs corpus files through lafleur.driver in a
shared globals dict. Corpus files are stored core-only, so session parents and
polluters were executed WITHOUT `import sys` — and their first line is the [fN]
marker `print(..., file=sys.stderr)`. The driver seeded shared_globals with only
__name__/__builtins__, so those scripts raised `NameError: name 'sys' is not
defined` before the boilerplate-carrying child ran and defined sys in the shared
namespace. A real session run (jit_run10) wasted 99.8% of its ignored-crashes on
this; only ~15% child-only "solo" sessions were unaffected, defeating the
warm-JIT purpose of session mode.

The earlier boilerplate fixes (#867/#878) only covered the normal per-script
path. Seed the driver's shared globals with sys, gc, collect, random, and a
default fuzzer_rng so every session script runs regardless of order; the child's
own boilerplate still overwrites fuzzer_rng with its seeded RNG.

Closes #883

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@devdanzin
devdanzin merged commit ca4bd00 into main Jul 1, 2026
2 checks passed
@devdanzin
devdanzin deleted the fix/session-driver-seed-globals branch July 1, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session driver execs core-only corpus files without seeding sys/gc/fuzzer_rng -> NameError storm

1 participant