printf stops working after command completion
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.
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)
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.
An extension of this is that printf isn't working when not running a command as well.