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 global initialization #3905

Merged
merged 1 commit into from
Nov 13, 2024

Conversation

sjamesr
Copy link
Contributor

@sjamesr sjamesr commented Nov 12, 2024

While resolving linked globals, WAMR tries to copy the linked global's initial value into the destination global in the current module. However, a bug in the implementation causes the copy to be done from the InitializerExpression struct, not from its WASMValue field.

This did not come up in WAMR's spec test runner because those are built with WASM_ENABLE_SPEC_TEST, which means these globals are resolved as builtins, not linked globals, which goes through a different (presumably not faulty) path.

While resolving linked globals in multi-module mode, WAMR tries to copy
the linked global's initial value into the destination global in the
current module.  However, a bug in the implementation causes the copy to
be done from the InitializerExpression struct, not from its WASMValue
field.

This did not come up in WAMR's spec test runner because those are built
with WASM_ENABLE_SPEC_TEST, which means these globals are resolved as
builtins, not linked globals, which goes through a different (presumably
not faulty) path.
Copy link
Collaborator

@lum1n0us lum1n0us left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice catch.

@sjamesr
Copy link
Contributor Author

sjamesr commented Nov 12, 2024

Thank you! I won't lie, it took a good day of debugging to figure this one out. 😄

Copy link
Collaborator

@xujuntwt95329 xujuntwt95329 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lum1n0us lum1n0us merged commit fdda259 into bytecodealliance:main Nov 13, 2024
382 of 383 checks passed
lum1n0us added a commit that referenced this pull request Nov 20, 2024
* Exclude fuzz test python and npm packages in scoreboard scan (#3871)
* Fix out of bounds issues after memory.grow on non-aot non-threads builds (#3872)
* fix(ios): Remove `float-abi` flag (#3889)
* build(deps): bump github/codeql-action from 3.26.13 to 3.27.0 (#3888)
* Refine looking up aot function with index (#3882)
* Bump AOT_CURRENT_VERSION for WAMR 2.x (gc, memory64) (#3880)
* Fix mmap flags for AOT loader on non-Linux SGX platforms (#3890)
* Fix out of bounds issue in is_native_addr_in_shared_heap function (#3886)
* Refactor AOT loader to support compatible versions (#3891)
* Wasm loader enhancement: check code size in code entry  (#3892)
* Fix linked global initialization in multimodule (#3905)
* build(deps): bump github/codeql-action from 3.27.0 to 3.27.1 (#3902)
* GlobalValueSet was moved to IRPartitionLayer recently, but we have a local definition anyway (#3899)
* Fix a leak in wasm_loader_emit_br_info (#3900)
* Correct the table index calculation in aot_instantiation (#3903)
* build(deps): bump github/codeql-action from 3.27.1 to 3.27.4 (#3912)
* Support external toolchain on Windows for aot compiler (#3911)
* Fix CI wamr-ide error (#3913)

Co-authored-by: TianlongLiang <[email protected]>
Co-authored-by: Maks Litskevich <[email protected]>
Co-authored-by: Deniz Sokmen <[email protected]>
Co-authored-by: edoardo <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: YAMAMOTO Takashi <[email protected]>
Co-authored-by: liang.he <[email protected]>
Co-authored-by: Fadumina Barre <[email protected]>
Co-authored-by: Marcin Kolny <[email protected]>
Co-authored-by: James Ring <[email protected]>
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.

4 participants