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

iwasm: WASM module load failed: struct or array as field is not supported in constant expr #3410

Open
bashor opened this issue May 9, 2024 · 6 comments

Comments

@bashor
Copy link

bashor commented May 9, 2024

Steps to reproduce

  1. Unpack zip kotlin-wasm-wasi-example-wasm-wasi-prod.wasm.zip
  2. Build iwasm with the following command
 cmake .. -DWAMR_BUILD_GC=1 -DWAMR_BUILD_BULK_MEMORY=1 -DWAMR_BUILD_EXCE_HANDLING=1 -DWAMR_BUILD_TAIL_CALL=1 -DWAMR_BUILD_CUSTOM_NAME_SECTION=1 -DWAMR_BUILD_EXCE_HANDLING=0 && make
  1. Run ./iwasm kotlin-wasm-wasi-example-wasm-wasi-prod.wasm

Expected behavior

It should print something like:

Hello from Kotlin via WASI
Current 'realtime' timestamp is: 1715281633864118000
Current 'monotonic' timestamp is: 210424654558083

Actual behavior

It prints:

iwasm: WASM module load failed: struct or array as field is not supported in constant expr
@TianlongLiang
Copy link
Contributor

I took a look at this case, it's due to the current implement limitation, we don't allow to init the global with references. The #3411 is also due to this limitation.

@bashor
Copy link
Author

bashor commented May 13, 2024

Any chance they will be fixed in the foreseeable future?

@TianlongLiang
Copy link
Contributor

We plan to take on that and will try our best to support this syntax, it could be a while through

@wenyongh
Copy link
Contributor

@bashor I submitted PR #3447, and now it should be able to run this case successfully in interpreter mode. But it only supports the nested constant initializer expression like struct.new struct.new (a struct's field is a struct), ref.func struct.new (a struct's field is a func obj). Just want to know is there requirement from you like array.new struct.new (a struct's field is an array), struct.new array.new (an array's element is a struct)? If yes, is there any case from you? Thanks.

@bashor
Copy link
Author

bashor commented May 19, 2024

@wenyongh Hi! Thanks for the fix! Could you please also check it on #3411? It's an unoptimized version and should contain more cases.

@wenyongh
Copy link
Contributor

@bashor Welcome, I looked into this case and fixed several issues in wasm loader, now iwasm can run this case successfully, please try PR #3447 again.

wenyongh added a commit that referenced this issue May 21, 2024
…y new (#3447)

Only support interpreter now, and fix some issues found in wasm loader.

This PR fixes issue #3410 and #3411.
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

3 participants