Skip to content

i64.const value couldn't read #799

Closed

Description

@pepyakin
AGFzbQEAAAABBAFgAAADAgEAChABDgBCgICAgICAgID/fhoL

This file is successfully loaded by the spec interpreter and binaryen.

But wasm2wat reports an error:

0000018: error: unable to read i64 leb128: i64.const value

Activity

  1. binji commented on Mar 8, 2018

    @binji
    Member

    I believe wabt is correct here (though the error message could be clearer), the value that is being parsed is 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0x80 0xff 0x7e. The encoding uses 7 bits per byte, so the first 9 bytes encode 63 bits. The least-significant bit of the 10th byte encodes the sign bit of the 64-bit value, and it is required that the 7 more-significant bits are a sign-extension of this bit (i.e. they match). In this case, 0x7e has the sign-bit cleared, but the following bits set, which is invalid.

    As confirmation, v8 also fails to load this module with a clearer error message:

    CompileError: WebAssembly.Module(): Compiling wasm function #0 failed: extra bits in varint @+33 
    
  2. pepyakin commented on Mar 9, 2018

    @pepyakin
    Author

    Oh, I see! I see that you created issue in the spec repo, thanks for that!

    Also I seen such behavior in wasm-dis, so cc @kripken

  3. kripken commented on Mar 12, 2018

    @kripken
    Member
  4. binji commented on Mar 16, 2018

    @binji
    Member

    OK, spec interpreter bug was fixed and binaryen has a bug filed, so closing here.

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

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions