preview2-prototyping icon indicating copy to clipboard operation
preview2-prototyping copied to clipboard

printf stops working after command completion

Open guybedford opened this issue 3 years ago • 3 comments

I've got a component which executes as a command via main(), after which exported functions may be called as part of an extended lifecycle for the application.

I'm finding that while these executions work correctly, and wasi-logging works correctly, printf only works correctly during the main() function, and after that its output is being entirely swallowed.

Here's a repo demonstrating the case - https://github.com/guybedford/wasi-command-export-printf. It's still a largeish component for Spidermonkey, I could possibly reduce it further, but perhaps the above is enough to track.

guybedford avatar Jan 09 '23 20:01 guybedford

I've looked through the code in wasi-libc and the polyfill and I've not found an obvious reason why stdout should stop working.

What version of wasm-tools are you using? Running the script in that repo fails with:

Error: decoding custom section component-type:wasi

Caused by:
    unsupported component version: 0xa (at offset 0x0)

sunfishcode avatar Jan 12 '23 01:01 sunfishcode

It should build against the version of wasm-tools from the main branch currently. If that's still not working I can try and come up with a simpler replication.

guybedford avatar Jan 12 '23 21:01 guybedford

An extension of this is that printf isn't working when not running a command as well.

guybedford avatar Jan 12 '23 22:01 guybedford