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

Fix memory initialization when offset is negative #7559

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

alexcrichton
Copy link
Member

This commit fixes a bug in initializing memory segments of 32-bit memories where if the offset was negative when viewed as a signed integer the offset was incorrectly sign-extended to a 64-bit value instead of zero-extended. This commit replaces an i32-to-u64 cast with an i32-to-u32 cast followed by a u32-to-u64 cast which performs the zero extend.

Closes #7558

This commit fixes a bug in initializing memory segments of 32-bit
memories where if the offset was negative when viewed as a signed
integer the offset was incorrectly sign-extended to a 64-bit value
instead of zero-extended. This commit replaces an `i32`-to-`u64` cast
with an `i32`-to-`u32` cast followed by a `u32`-to-`u64` cast which
performs the zero extend.

Closes bytecodealliance#7558
@alexcrichton alexcrichton requested a review from a team as a code owner November 20, 2023 15:09
@alexcrichton alexcrichton requested review from pchickey and removed request for a team November 20, 2023 15:09
@alexcrichton alexcrichton added this pull request to the merge queue Nov 20, 2023
Merged via the queue into bytecodealliance:main with commit 05eadca Nov 20, 2023
18 checks passed
@alexcrichton alexcrichton deleted the fix-cast branch November 20, 2023 18:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Different output when running the same wasm file in aot mode
2 participants