Skip to content

GHC produces an incorrect DWARF .debug_aranges section in some cases

Summary

When parsing the .debug_aranges section of code produced by GHC (for example using the folly symboliser) the parsing fails because of an incorrect value of the length field.

The bug seems to be here: https://gitlab.haskell.org/ghc/ghc/blob/4898df1cc25132dc9e2599d4fa4e1bbc9423cda5/compiler/nativeGen/Dwarf/Types.hs#L233 where the initialLength is set to a constant value, while the length should depend on the amount of address range entries in a given section. It seems to have been introduced in this commit: 4a32bf92 where the capability to create a .debug_aranges section with multiple address ranges was added, but the calculation for initialLength was not changed.

Environment

  • GHC version used: 8.4.4
Edited by Szymon Nowicki-Korgol
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information