Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lightbeam] remainder overflow in debug mode (backend:rem_s:868) #837

Closed
pventuzelo opened this issue Jan 17, 2020 · 1 comment
Closed
Labels
lightbeam Issues related to the Lightbeam compiler

Comments

@pventuzelo
Copy link
Contributor

Issue description

lightbeam will try to calculate the remainder even if an overflow occurs in the function rem_s.

$ ./debug_diff_compile panic_remainder_overflow_868_2.wasm 
thread 'main' panicked at 'attempt to calculate the remainder with overflow', XXX/wasmtime/crates/lightbeam/src/backend.rs:868:56
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

This issue is related to the function rem_s when dealing with the i32.rem_s opcode:

} else {
self.push(ValueLocation::Immediate((dividend % divisor).into()))?;
}

I suspect this issue can also occurs in rem_u:

self.push(ValueLocation::Immediate(
(dividend as $unsigned_ty % divisor as $unsigned_ty).into(),
))?;
}

Reproduction

Download
panic_remainder_overflow_868.zip

(module
  (type (;0;) (func (result i32)))
  (func (;0;) (type 0) (result i32)
    i32.const -2147483648
    i32.const -1
    i32.rem_s
    unreachable))

wasmtime commit: 7890fa6

@alexcrichton alexcrichton added the lightbeam Issues related to the Lightbeam compiler label Feb 20, 2020
arkpar pushed a commit to paritytech/wasmtime that referenced this issue Mar 4, 2020
@alexcrichton
Copy link
Member

Lightbeam was removed in #3390 as explained in RFC 14, so I'm going to close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lightbeam Issues related to the Lightbeam compiler
Projects
None yet
Development

No branches or pull requests

2 participants