Open bashor opened 6 months ago
Hi, would you mind telling me which toolchain you are using? I wasn't aware that Kotlin has standalone support for wasm, I would love to give it a try if it's publicly accessible
@TianlongLiang Hi! Kotlin Multiplatform toolchain supports wasm out of the box. Check out https://kotl.in/wasm or https://kotl.in/wasm-examples.
I'm working on Kotlin/Wasm (with other folks), so feel free to reach out if you have any questions.
Thanks, I will definitely check it out!
Please try #3447.
Hi, @wenyongh @TianlongLiang! Thanks for fixes, it really helped with attached examples.
Previous binaries was compiled with disabled EH on Kotlin side, after turning it on I got the a similar error. Here is a new binary --kotlin-wasm-wasi-example-wasm-wasi.wasm.zip
@bashor Welcome. Could you upload the wast file also? It is a little complex to analyze the wasm file without wast info, I used the tool compiled from wasm GC MVP spec proposal, but it reports: decoding error: malformed section id
.
@wenyongh Here is a wat file I got using Binaryen's wasm-dis -- kotlin-wasm-wasi-example-wasm-wasi.wasm.wat.zip
$ wasm-dis --enable-gc --enable-reference-types --enable-exception-handling --enable-bulk-memory kotlin-wasm-wasi-example-wasm-wasi.wasm -o kotlin-wasm-wasi-example-wasm-wasi.wasm.wat
@bashor I tried to debug it but since I am not familiar with the exception handling, I am not sure whether it is caused by the case itself, or by exception handling, or by the GC implementation. And the wasm file is really big and there are too many GC types, I need more time to try.
@wenyongh Hi! Here is a smaller version -- kotlin-wasm-wasi-example-wasm-wasi.wasm-prod.zip. Hope it will be easier to inspect.
-- Also, you can find a version optimized with Binaryen here. kotlin-wasm-wasi-example-wasm-wasi.wasm-prod-opt.zip
With the optimized version, wami fails differently:
iwasm(872,0x1f55e8c00) malloc: *** error for object 0x600000000003: pointer being freed was not allocated
iwasm(872,0x1f55e8c00) malloc: *** set a breakpoint in malloc_error_break to debug
zsh: abort
@bashor thanks for the wat files and the new samples, there are several issues in the handling of exception handling and GC, I submitted PR #3586 to fix them and now all the files run successfully. Please try again.
@wenyongh Nice, thanks! I'll try it and let you know.
@wenyongh confirm, with #3586, the simple example works. Thanks! I found some other bugs and am going to file separate issues for them.
@bashor welcome, please feel free to file issues, we will try to fix them.
@wenyongh JFYI I've just filed #3598 and #3599
Steps to reproduce
Unpack zip kotlin-wasm-wasi-example-wasm-wasi-dev.wasm.zip
Build
iwasm
with the following commandRun
./iwasm kotlin-wasm-wasi-example-wasm-wasi-dev.wasm
Expected behavior
It should print something like:
Actual behavior
It prints: