0xMiden / 0xMiden/compiler

miscompilation: signed widening arithmetic diverges from native execution

未关闭
#1,288 3 条评论 0 个 reaction 已指派 1 人 已被 @mooori 认领 在 GitHub 查看
主要语言
Rust
星标
115
派生
84
平均合并
1 天 8 小时
30 天内合并 PR
15

描述

The differential fuzzing suite found a silent wrong-result miscompilation (no VM abort): a `(u32, u32) -> u32` function mixing `i64.extend8/16/32_s`, `i64.extend_i32_s`, and `i64.mul_wide_s` (one negative-constant and one dynamic multiplicand) returns a different value under the Miden VM than natively.

For inputs `(3022925119, 3340151117)`: native `3550407903` vs MASM `3550391763`.

## Reproduce

On the branch from #1286:

```sh
cargo test -p midenc-integration-tests differential::tests::sext_shapes_repro -- --ignored
```

`sext_shapes_repro` pins the failing input pair and fails deterministically; `sext_shapes` runs the same case under 16 random inputs. The case source is `tests/integration/src/end_to_end/differential/cases/case_sext_shapes.rs`; both tests are `#[ignore]`d in `tests/integration/src/end_to_end/differential/tests.rs`.

## Already bounded

Passing sibling cases show each ingredient is correct in isolation:

- `sext_widths` — pure extend8/16/32_s chains
- `mulwide_dyn` — dynamic-by-dynamic `i64.mul_wide_s`
- `mulwide_fold` — `mul_wide_s` with a *positive* constant multiplicand

The remaining suspects are the negative-constant multiplicand shape (the one piece no passing sibling covers) or an interaction between the shapes.

贡献指南

打开贡献指南

调研方向

The failing test is in `tests/integration/src/end_to_end/differential/tests.rs` as `sext_shapes_repro`. Examine the case source `case_sext_shapes.rs` to see the function mixing signed extensions and multiplication. Run the test to confirm the divergence, then trace through the compiler's handling of `i64.extend8/16/32_s`, `i64.extend_i32_s`, and `i64.mul_wide_s` with a negative constant. Compare the generated Miden Assembly to the expected native execution.

由索引模型根据 Issue 内容生成。

评估

技术栈
rust
领域
compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。