Skip to content

Warm fasl cache duplicates the output of nested (load)s #92

Closed

Description

@pyrex41

Found while running capcov's f-modelcheck workload across ports. It reproduces on main e3dec8b (LuaJIT 2.1.1785763465, macOS arm64). The #84–#88 PRs (#89, #90, #91) don't cause it.

Repro

mkdir fasl-dup && cd fasl-dup
printf '(output "LIB~%%")\n' > lib.shen
printf '(output "BEGIN~%%")\n(load "lib.shen")\n(define reload X -> (load X))\n(reload "lib.shen")\n(output "END~%%")\n' > main.shen
export SHEN_FASL_DIR=$PWD/fasl
for i in 1 2 3; do shen --hush-load main.shen | tr '\n' '|'; echo; done

Output at e3dec8b:

BEGIN|LIB|LIB|END|              <- cold fasl cache: correct
BEGIN|LIB|LIB|LIB|LIB|END|      <- warm: every LIB is printed twice
BEGIN|LIB|LIB|LIB|LIB|END|

Control: with SHEN_FASL=off the output is BEGIN|LIB|LIB|END| on every run. shen-go 1f587de prints LIB twice, plus its load echo.

A plain top-level (load "lib.shen") in main.shen has the same problem. With main.shen as (output "BEGIN~%") (load "lib.shen") (load "lib.shen") (output "END~%"), the cold run prints BEGIN|LIB|LIB|END| and the warm run prints BEGIN|LIB|LIB|LIB|LIB|END|. So the trigger is output inside a file that a cached file loads; it doesn't matter where the nested load is called from. My guess is that on a fasl hit for main.shen, the replay emits the nested file's output once from the outer record stream and again from the nested load. I haven't confirmed this.

Impact

capcov f-modelcheck registers its judges with (load Path) from inside mc.judge-all. Its first run prints 25 MC lines, identical to shen-go. Every later run prints 36: 11 JUDGE/PASS lines are duplicated. The workload's result therefore depends on the state of the cache.

Generated by Claude Code

Activity

  1. changed the title [-]Warm fasl cache duplicates the output of a (load) called from inside a function[/-] [+]Warm fasl cache duplicates the output of nested (load)s[/+] on Oct 19, 2026
  2. added a commit that references this issue on Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions