Exit code is wrong with dynamically loaded libraries
|Reported by:||Lennart||Owned by:|
|Type of failure:||None/Unknown||Difficulty:|
|Test Case:||ffi/should_run/5402||Blocked By:|
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().
Change History (12)
Changed 3 years ago by malcolmw
comment:9 Changed 3 years ago by simonmar
- Milestone set to 7.4.1
- Resolution set to fixed
- Status changed from new to closed
- Test Case set to ffi/should_run/5402
comment:10 Changed 2 years ago by simonmar
- Milestone changed from 7.4.1 to 7.2.2
- Status changed from closed to merge