Exit code is wrong with dynamically loaded libraries
Here's a simple scenario that goes wrong:
Program starts, calls hs_init(), hs_init_count=1
Program loads some Haskell library that calls hs_init(), hs_init_count=2.
Program does exitWith 99, which calls shutdownHaskellAndExit(99), which calls hs_exit_(). Since hs_init_count>1 it will do nothing. Control returns to shutdownHaskellAndExit, since hs_init_count>0 it will do nothing, i.e., it throws away the exit code 99.
Now real_main() gets control back, and calls shutdownHaskellAndExit(0). The whole program now exits with code 0, rather than 99.
The solution is probably to track the last non-0 exit code encountered in shutdownHaskellAndExit and use that as the exit code in real_main().
Trac metadata
| Trac field | Value |
|---|---|
| Version | 7.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Runtime System |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |