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

Panic compile to wasm32-unknown-unknown target #2182

Closed
jht5945 opened this issue Jul 17, 2022 · 0 comments
Closed

Panic compile to wasm32-unknown-unknown target #2182

jht5945 opened this issue Jul 17, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@jht5945
Copy link

jht5945 commented Jul 17, 2022

Describe the bug

Compile boa_engine to wasm32, panic when create empty array.

file: boa_engine/src/buildins/array/mod.rs

    pub(crate) fn array_create(
        length: usize,
        prototype: Option<JsObject>,
        context: &mut Context,
    ) -> JsResult<JsObject> {
        // 1. If length > 2^32 - 1, throw a RangeError exception.
        if length > 2usize.pow(32) - 1 {
            return context.throw_range_error("array exceeded max size");
        }

Change this line if length > to:

if length > u32::MAX as usize {

To Reproduce
Compile boa to was32 or other 32bit targets.

Create a empty array cause panic, like:

let a = [];

Expected behavior

2 ^ 32 panic under 32bit arch

Build environment (please complete the following information):

  • OS: MacBook Pro
  • Version: [e.g. 32]
  • Target triple: wasm32-unknown-unknown
  • Rustc version: 1.60.0 (7737e0b5c 2022-04-04)

Additional context
n/a

@jht5945 jht5945 added the bug Something isn't working label Jul 17, 2022
@HalidOdat HalidOdat self-assigned this Jul 20, 2022
@bors bors bot closed this as completed in efff9d6 Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants