Skip to content

Fix validating imported global refs - #2848

Merged
zherczeg merged 1 commit into
WebAssembly:mainfrom
zherczeg:import_ref
Sep 15, 2026
Merged

zherczeg merged 1 commit into
WebAssembly:mainfrom
zherczeg:import_ref

Conversation

@zherczeg

@zherczeg zherczeg commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Found by George Vasiliades

@zherczeg

zherczeg commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

@Poseidonas fix for a bug you have found.

@Poseidonas

Copy link
Copy Markdown

Thanks, Zoltan — and thanks for taking it upstream. That reference-type index check is an easy one to miss, so it makes sense the same gap turns up across implementations; catching it at the toolkit level is where it matters most. Glad it landed with a regression test, and happy to help however is useful.

)
(;; STDERR ;;;
out/test/parse/bad-ref-globals.txt:5:42: error: reference 9997 is out of range (max: 0) in globals
(global (import "mod" "val") (ref 9997))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Note: imported / not imported globals display the error location differently.

This could be fixed by passing loc instead of GetLocation():
https://github.com/WebAssembly/wabt/blob/main/src/wast-parser.cc#L1865

There are other similar cases though.

@zherczeg

zherczeg commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator Author

This issue is likely my fault. I did it when I implemented the function references proposal.

@sbc100

sbc100 commented Sep 14, 2026

Copy link
Copy Markdown
Member

Perhaps at refs to the PR title? (Since this only applies to reference types, correct?)

@zherczeg zherczeg changed the title Fix validating imported globals Fix validating imported global refs Sep 15, 2026
Found by George Vasiliades
@zherczeg
zherczeg merged commit 505d71c into WebAssembly:main Sep 15, 2026
17 checks passed
@zherczeg
zherczeg deleted the import_ref branch September 15, 2026 04:01
@Poseidonas Poseidonas moved this from Waiting on review to Done in Industrial open source Sep 15, 2026
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.

3 participants