Skip to content

[wasm] Int64 marshaling is corrupting data which could not fit JS Number  #69394

Closed

Description

@pavelsavara

Description

JavaScript Number is float64 type. Integers outside of Number.MAX_SAFE_INTEGER and Number.MIN_SAFE_INTEGER can't be represented.

Out current code from emscripten is

getValue

case 'i64': return HEAP32[((ptr)>>2)];

And setValue

case 'i64': (tempI64 = [value>>>0,(tempDouble=value,(+(Math.abs(tempDouble))) >= 1.0 ? (tempDouble > 0.0 ? ((Math.min((+(Math.floor((tempDouble)/4294967296.0))), 4294967295.0))|0)>>>0 : (~~((+(Math.ceil((tempDouble - +(((~~(tempDouble)))>>>0))/4294967296.0)))))>>>0) : 0)],HEAP32[((ptr)>>2)] = tempI64[0],HEAP32[(((ptr)+(4))>>2)] = tempI64[1]); break;

Reproduction Steps

Net 7.0 preview 4 and below on WASM.

Expected behavior

Use available 52 bits both directions and throw on overflow.
Give user option to marshal also as BigInt

Actual behavior

Value is trimmed to 32bits only.

Regression?

No

Known Workarounds

use double on C# side too.

Activity

  1. self-assigned this
    on May 16, 2022
  2. ghost added
    untriagedNew issue has not been triaged by the area owner
    on May 16, 2022
  3. removed
    untriagedNew issue has not been triaged by the area owner
    on May 16, 2022
  4. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Jun 6, 2022
  5. added this to the 7.0.0 milestone on Jun 25, 2022
  6. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Jul 10, 2022
  7. ghost locked as resolved and limited conversation to collaborators on Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions