Don't barf on failures in the RTS linker
The RTS linker currently calls
barf() when it fails. This is a problem because:
- It appears that there is a bug in GHC, when there is no bug.
- Failures to load code really should be recoverable.
According to a
TODO in the code, the culprit is resource deallocation, which is very difficult due to the code being written in C and having complicated control flow. There are a few solutions:
- Port the RTS linker to C++ and use RAII for resource management. Failures would be handled (internally to the linker) by throwing a C++ exception. This is actually my favorite, but might not be popular with the GHC devs.
- Build a huge context struct containing all needed resources and free it before returning. Signal errors with
- Try to find each and every place where resources need to be free, and free them by hand. Signal errors with return codes. This seems too error-prone.
|Component||Runtime System (Linker)|