Skip to content

Panic: i32::MIN % -1 remainder overflow #5481

Description

@domenukk

Describe the bug
Panic / Unreachable when running

(-2147483648 | 0) % (-1 | 0)

Expected behavior
Not crash

boa_engine-0.21.1/src/value/operations.rs:157

// Line 150-161:
pub fn rem(&self, other: &Self, context: &mut Context) -> JsResult<Self> {
    Ok(match (self.variant(), other.variant()) {
        // Fast path:
        (JsVariant::Integer32(x), JsVariant::Integer32(y)) => {
            if y == 0 {
                Self::nan()
            } else {
                match x % y {  // ← LINE 157: PANICS when x=i32::MIN, y=-1
                    rem if rem == 0 && x < 0 => Self::new(-0.0),
                    rem => Self::new(rem),
                }
            }
        }

Activity

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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions