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

handling of function imports during module instantiation #3908

Open
sjamesr opened this issue Nov 13, 2024 · 1 comment
Open

handling of function imports during module instantiation #3908

sjamesr opened this issue Nov 13, 2024 · 1 comment

Comments

@sjamesr
Copy link
Contributor

sjamesr commented Nov 13, 2024

Hi all, I was just wondering why module imports are treated specially during module instantiation (compared to table, global and memories). If a linked global, table or memory cannot be found, check_linked_symbol will return false, e.g. see https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/iwasm/interpreter/wasm_runtime.c#L1914.

On the other hand, a missing function will log a warning, but will not otherwise prevent module instantiation. Unless I'm misunderstanding, this seems to contradict Rule 3 in https://webassembly.github.io/spec/core/exec/modules.html#exec-instantiation.

I came across this while writing my own spec test runner. In imports.wast spec test, we have

(assert_unlinkable
  (module (import "test" "unknown" (func)))
  "unknown import"
)

WAMR's spec test runner checks to see that there is a linker failure in the STDOUT or STDERR of the iwasm repl, which there is. But this failure does not actually prevent module instantiation like the spec says it should.

I'm curious about WAMR's behavior in this scenario. It seems like a deliberate choice, but I'd like to understand why. Thanks!

@TianlongLiang
Copy link
Contributor

I think the choice of warning over error is that this import function may not be used. If it's actually used, it will report an exception error in runtime.

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

No branches or pull requests

2 participants