Fix: writeI53ToI64 crashes with -sASSERTIONS=2 when num >= 2^32#26410
Open
49iohcy wants to merge 1 commit intoemscripten-core:mainfrom
Open
Fix: writeI53ToI64 crashes with -sASSERTIONS=2 when num >= 2^32#2641049iohcy wants to merge 1 commit intoemscripten-core:mainfrom
-sASSERTIONS=2 when num >= 2^32#2641049iohcy wants to merge 1 commit intoemscripten-core:mainfrom
Conversation
…a num ge 4294967296 (u32 max + 1) is passed.
sbc100
reviewed
Mar 8, 2026
Collaborator
sbc100
left a comment
There was a problem hiding this comment.
Thanks for the tracking down!
I guess we are missing a test for this. Perhaps we can expand test/core/test_int53.c to include a test here.
sbc100
reviewed
Mar 8, 2026
| // C/C++ side code to interpret the resulting number as signed or unsigned as is desirable. | ||
| $writeI53ToI64: (ptr, num) => { | ||
| {{{ makeSetValue('ptr', 0, 'num', 'u32') }}}; | ||
| {{{ makeSetValue('ptr', 0, 'num&0xFFFFFFFF', 'u32') }}}; |
Collaborator
There was a problem hiding this comment.
I think we normally write this as num >>> 0
Author
There was a problem hiding this comment.
Thanks for the feedback. I'll see what I can do with the test and let you know!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello.
I've recently been working on a WebGPU demo w/ Dawn WebGPU C/C++ implementation. When I tried to get the adapter limit in a node:24-slim devcontainer on my M2 Apple Silicon, I got 4294967296 for the
maxBufferSize, which is a valid parameter forwriteI53ToI64.When
-sASSERTIONS=2is set, there's a trailingcheckInt32call in themakeSetValueimplementation. Without masking the low word ofnum,checkInt32throws in the current implementation oflibint53.mjs, which I believe is not the desired behavior.The following are relevant references for the most up-to-date implementations of Emscripten and Dawn.
https://github.com/google/dawn/blob/89b4626b4e838738227dc410209c4d03410d94a9/third_party/emdawnwebgpu/pkg/webgpu/src/library_webgpu.js#L581
emscripten/src/parseTools.mjs
Lines 494 to 502 in f7179e4
emscripten/src/lib/libint53.js
Lines 21 to 30 in f7179e4