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
longjmp(). - 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.
Trac metadata
| Trac field | Value |
|---|---|
| Version | 8.0.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Runtime System (Linker) |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture |