-
Notifications
You must be signed in to change notification settings - Fork 39
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
WasiExitException thrown every time proc_exit is called #533
Comments
I'm convinced that the current implementation is about "the best" we can offer in terms of consistency. Regarding your options:
FWIW, additional context is that the only compiler(I'm aware of) that makes use of this Wasi function is the "standard" Go compiler. |
My assumption was that proc_exit is a proxy for the exit syscall, so it's not necessarily compiler specific as any c or rust program could call exit. though i may be wrong there. If the answer is to leave it the way it is, that's fine I think. maybe we just document that it may throw this exception and you need to catch it. Or put it in the example in the Readme |
It shouldn't, but, apparently, it's not widely used in practice. Fun fact, looking closer at this, if you don't throw the Exception nor explicitly stop the runtime while running "standard Go" the runtime is going to fail trying to perform a "sleep"(and we don't have the wasi function implemented for it yet). |
I assume this is because you actually need to explicitly stop the program, which the exception is implicitly doing. There is code after the exit but it should never be executed because calling the syscall on an OS would halt the program. FWIW it does seem that any time you call exit it's turning that into proc_exit. Verified with: #include <stdlib.h>
#include <stdio.h>
int main() {
printf("This program will now exit.\n");
exit(0);
printf("This line will not be printed.\n");
return 0;
} |
Thanks for looking closer at it! According to those further findings, I think that "always throwing an exception"(current implementation) is the most idiomatic way to implement the |
As you've shown, the |
I think this one can be closed, feel free to open a new one or re-open if necessary. |
Reported in Zulip by Stefan
It appears this exception is being thrown even when the program exits successfully: https://github.com/dylibso/chicory/blame/b69237737c6f05f74d4c3fafbb1e32a350953e9a/wasi/src/main/java/com/dylibso/chicory/wasi/WasiPreview1.java#L1043
I think there are two options to fix:
Though I think it depends on what was the intention behind the exception so perhaps @electrum can provide some insight.
The text was updated successfully, but these errors were encountered: