Emscripten: PROXY_TO_PTHREAD causes runtime to exit despite NO_EXIT_RUNTIME

Created on 27 Feb 2019  路  9Comments  路  Source: emscripten-core/emscripten

Example:

#include <iostream>
int main(int argc, char** argv) {
    std::cout << "I shouldn't exit" << std::endl;
}

Compile like:
emcc test.cpp -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1 -s NO_EXIT_RUNTIME=1 -o test.html

The following gets logged to the console:

15:03:52.887 Preallocating 1 workers for a pthread spawn pool. test.html:1237:13
15:03:53.018 I shouldn't exit test.html:1237:13
15:03:53.020 ExitStatus: Program terminated with exit(0) test.js:7291:24

This is not personally an issue for me, just something I ran into when testing. I figured I should log it anyway.

help wanted

All 9 comments

Shutting down the runtime also prevents calling functions (for example with Module.ccall(...)) later on.

Since this might be a bit of a niche issue I put a $100 bounty on it.

Wow, is this the first emscripten bounty? Very exciting. Somebody will go for it I'm sure.

@juj mentioned a workaround in https://github.com/emscripten-core/emscripten/issues/8969#issuecomment-511328047: EM_ASM(Module['noExitRuntime'] = true);

I was investigating related behavior in #9251 and I tried running with atexit() handlers registered, and it appears that they correctly do not get run. Also it doesn't appear that browsers currently log ExitStatus results. So I'm a bit unsure what behavior this bug is referring to? Is this a node application?

When I reported this I was seeing this in a browser. Perhaps things changed since February?
Also I'm pretty sure that previously this code was getting hit on exit: https://github.com/emscripten-core/emscripten/blob/bef558affb630141e9fb0e955a9c444a87fb73fe/src/postamble.js#L153-L157

Just tested this with 1.38.43. Exit code doesn't get logged, but the program still terminates.
This can be verified by putting a breakpoint in the ExitStatus function mentioned in the above comment.

Make sure you collect your bounty @juj :)

Oh wait what, there was a bounty? That is very cool! :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HolgerStrauss picture HolgerStrauss  路  4Comments

nerddan picture nerddan  路  4Comments

nemequ picture nemequ  路  4Comments

hcomere picture hcomere  路  3Comments

juj picture juj  路  3Comments