0xPolygonMiden / compiler

Compiler from MidenIR to Miden Assembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Emulator fails to execute code `eq_*64` that VM executes fine

greenhat opened this issue · comments

On the following MASM:

# mod test_rust_23a27398cbfb7447cb610e7b877565f4e43d633b55f98504051b93381d40740f

export.entrypoint
    movdn.3
    movdn.3
    movup.2
    eq
    movdn.3
    eq
    and
end


begin
    exec.::test_rust_23a27398cbfb7447cb610e7b877565f4e43d633b55f98504051b93381d40740f::entrypoint  
end

With error:

thread 'rust_masm_tests::instructions::eq_i64' panicked at /Users/dzadorozhnyi/src/miden-ir/hir/src/asm/stack.rs:284:9:
invalid operand stack index (3), only 2 elements are available
stack backtrace:
   0: rust_begin_unwind
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:645:5
   1: core::panicking::panic_fmt
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/panicking.rs:72:14
   2: midenc_hir::asm::stack::Stack::movdn
             at /Users/dzadorozhnyi/src/miden-ir/hir/src/asm/stack.rs:284:9
   3: midenc_codegen_masm::emulator::Emulator::run_once
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/emulator/mod.rs:1296:21
   4: midenc_codegen_masm::emulator::Emulator::step
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/emulator/mod.rs:1076:27
   5: midenc_codegen_masm::emulator::Emulator::run
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/emulator/mod.rs:1168:25
   6: midenc_codegen_masm::emulator::Emulator::invoke_function
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/emulator/mod.rs:676:17
   7: midenc_codegen_masm::emulator::Emulator::invoke
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/emulator/mod.rs:627:46
   8: midenc_codegen_masm::emulator::Emulator::start
             at /Users/dzadorozhnyi/src/miden-ir/codegen/masm/src/emulator/mod.rs:520:21
   9: miden_integration_tests::exec_emulator::execute_emulator
             at ./src/exec_emulator.rs:19:25
  10: miden_integration_tests::rust_masm_tests::run_masm_vs_rust
             at ./src/rust_masm_tests/mod.rs:32:25
  11: miden_integration_tests::rust_masm_tests::instructions::eq_i64::{{closure}}
             at ./src/rust_masm_tests/instructions.rs:35:25
  12: core::ops::function::impls::<impl core::ops::function::Fn<A> for &F>::call
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:262:13
  13: proptest::test_runner::runner::call_test::{{closure}}
             at /Users/dzadorozhnyi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proptest-1.4.0/src/test_runner/runner.rs:256:49
  14: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/panic/unwind_safe.rs:272:9
  15: std::panicking::try::do_call
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:552:40
  16: ___rust_try
  17: std::panicking::try
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panicking.rs:516:19
  18: std::panic::catch_unwind
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/std/src/panic.rs:146:14
  19: proptest::test_runner::runner::call_test
             at /Users/dzadorozhnyi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proptest-1.4.0/src/test_runner/runner.rs:256:9
  20: proptest::test_runner::runner::TestRunner::shrink
             at /Users/dzadorozhnyi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proptest-1.4.0/src/test_runner/runner.rs:845:30
  21: proptest::test_runner::runner::TestRunner::run_one_with_replay
             at /Users/dzadorozhnyi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proptest-1.4.0/src/test_runner/runner.rs:735:27
  22: proptest::test_runner::runner::TestRunner::gen_and_run_case
             at /Users/dzadorozhnyi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proptest-1.4.0/src/test_runner/runner.rs:664:23
  23: proptest::test_runner::runner::TestRunner::run_in_process_with_replay
             at /Users/dzadorozhnyi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proptest-1.4.0/src/test_runner/runner.rs:613:26
  24: proptest::test_runner::runner::TestRunner::run_in_process
             at /Users/dzadorozhnyi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proptest-1.4.0/src/test_runner/runner.rs:570:9
  25: proptest::test_runner::runner::TestRunner::run
             at /Users/dzadorozhnyi/.cargo/registry/src/index.crates.io-6f17d22bba15001f/proptest-1.4.0/src/test_runner/runner.rs:413:13
  26: miden_integration_tests::rust_masm_tests::instructions::eq_i64
             at ./src/rust_masm_tests/instructions.rs:29:27
  27: miden_integration_tests::rust_masm_tests::instructions::eq_i64::{{closure}}
             at ./src/rust_masm_tests/instructions.rs:14:27
  28: core::ops::function::FnOnce::call_once
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:250:5
  29: core::ops::function::FnOnce::call_once
             at /rustc/2d24fe591f30386d6d5fc2bb941c78d7266bf10f/library/core/src/ops/function.rs:250:5

To reproduce:

  1. in #227
  2. Uncomment
    // let emul_out: T = (*execute_emulator(ir_program.clone(), args).first().unwrap()).into();
    // prop_assert_eq!(rust_out, emul_out, "Emulator output mismatch");
    to run the compiled MASM on the emulator along the VM.
  3. Run cargo test eq_

@greenhat What arguments are being fed to the program? I'll take a look at this and #174.

@greenhat What arguments are being fed to the program? I'll take a look at this and #174.

I think on any values. I remember seeing proptest shrunk to zeroes.