Skip to content

Fix validating imported globals - #2848

Open
zherczeg wants to merge 1 commit into
WebAssembly:mainfrom
zherczeg:import_ref
Open

Fix validating imported globals#2848
zherczeg wants to merge 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

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.

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.

2 participants