xls icon indicating copy to clipboard operation
xls copied to clipboard

Fuzzer crash 2026-09-14_ce8a

Open dplassgit opened this issue 2 months ago • 1 comments

Repro:

bazel test -c opt  //xls/fuzzer:run_crasher_test_2026-09-14_ce8a

Error message:

Error: NOT_FOUND: Output `out`, instance #127 holds X value in Verilog simulator output.
=== Source Location Trace: === 
xls/simulation/module_testbench.cc:370
xls/simulation/module_testbench.cc:456
xls/simulation/module_simulator.cc:510
xls/simulation/module_simulator.cc:550
xls/tools/simulate_module_main.cc:208

dplassgit avatar Sep 15 '26 13:09 dplassgit

We think this comes from concat_select_removal running on scheduled IR in the default codegen (1.5). When the return value is a concat of same-selector selects that are scheduled in an earlier stage, the pass replaces the concat with a select of concats placed in the selects' stage. The pipeline registers between that stage and the output then disappear, but the signature still reports the scheduled latency. Outputs therefore arrive early (one cycle early for this crasher), and sample #127 is read after the inputs have gone X.

Cause (our reading), at 54b1b49b (main on 2026-10-11 UTC):

  • CanMerge checks that the selects share a stage with each other, but not with the concat that consumes them (concat_select_removal_pass.cc L62-L84).
  • TransformToSelectOfConcats adds the new concats and the new select to the first select's stage (L204-L236). DoTransform then calls ReplaceUsesWith on the later-stage concat (L261-L264).
  • The v1.5 pipeline runs this pass right after scheduling and before pipeline_register_insertion (codegen_pass_pipeline.txtpb L20-L38).

For crasher ce8a, --ir_dump_path shows the pass turning stage 4's ret x6: bits[21] = concat(x6__17_to_21, x6__0_to_17) into a priority_sel of concats in stage 3. We replayed its 128 inputs on Icarus with the crasher's codegen flags, plus --delay_model=unit as the sample runner adds. With default codegen, each output for samples 0-126 equals the reference result for the next sample, and #127 is X. With --codegen_version=1, all 128 match.

Minimal reproducer (release v0.0.0-10808-g54b1b49ba, no Bazel):

fn main(a: u5, b: u5, i: u1) -> u10 { (if i { a } else { b }) ++ (if i { b } else { a }) }

Save the DSLX above as swap.x, then run:

ir_converter_main swap.x --top=main > swap.ir
opt_main swap.ir > swap.opt.ir
codegen_main swap.opt.ir --generator=pipeline --delay_model=unit --pipeline_stages=4 \
  --use_system_verilog=false --module_name=swap \
  --output_verilog_path=swap.v --output_signature_path=swap.sig

Input and output flopping use the defaults (--flop_inputs=true --flop_outputs=true). The signature reports latency: 5, but the Verilog has only the input flops, one merged select and the output flops, and the measured latency is 2. On Icarus, 23 of 24 vectors are wrong at latency 5. For the valid-interface configuration, add --input_valid_signal=in_vld --output_valid_signal=out_vld --reset=rst to the codegen command. The valid-interface bench applies reset. With --input_valid_signal/--output_valid_signal, 3 of 4 back-to-back results are wrong. So a function pipeline like this returns another input's result at the reported latency and when out_vld is high. The same design passes with --codegen_version=1 or --pipeline_stages=1. It also passes if concat_select_removal runs before scheduling (opt_main --passes='concat_select_removal dce', then the same default codegen). That points to the stage placement, not the rewrite itself.

#5003 (crasher e540) looks like the same mechanism. The same rewrite moves its return from stage 9 to stage 8, each of the first 127 default-codegen outputs matches the next sample's reference, and --codegen_version=1 gives 0 of 128 wrong. #5002 shows the same symptom, but we didn't check its crasher.

These were independent release-binary/Icarus replays using Icarus 14.0 devel (s20260301-531-g633cc63a1-dirty). We did not run the Bazel crasher targets or simulate_module_main, and e540's codegen-2 leg was not checked.

We haven't written or tested a fix. The DSLX, scripts and Icarus benches are available under CC0 if they're useful as tests.

The original scripts exit zero even when they print mismatches. Read the LATENCY_CHECK/VALID_CHECK mismatch counters and the per-result WRONG lines.

Found by ChipLab's AI verification agents. Reproduced independently on Icarus with the release binaries.

ChipLab ref: CLAB-2026-077

vera-rubin avatar Oct 11 '26 23:10 vera-rubin