Skip to content

Don't barf on failures in the RTS linker

The RTS linker currently calls barf() when it fails. This is a problem because:

  1. It appears that there is a bug in GHC, when there is no bug.
  2. 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
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information