You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ghc-lib-parser causes segfaults when used together with the ghc library on ghc-9.10 #620
The FastString table built into GHC changed recently.
Since this table is shared by all versions of the GHC source code via an RTS symbol this causes segfaults when ghc-lib-parser-9.12 and ghc-9.10 are used together since they use different memory layouts for this table.
The fix for this is either to change GHC.Data.FastString such that the sharedCAF mechanism is not used. However that means FastStrings created by ghc-lib-parser and ghc are never allowed to be mixed.
The other alternative is to use CPP to adjust the memory layout of the faststring table depending on the GHC version used.
I don't know where to put this as a PR, but I'm guessing a patch would look something like this:
diff --git a/compiler/GHC/Data/FastString.hs b/compiler/GHC/Data/FastString.hs
index 017a8d3926a..c72a24cf16b 100644
--- a/compiler/GHC/Data/FastString.hs+++ b/compiler/GHC/Data/FastString.hs@@ -310,6 +310,7 @@ data FastStringTable = FastStringTable
{-# UNPACK #-} !FastMutInt
-- ^ The unique ID counter shared with all buckets
--
+#if MIN_VERSION_ghc(9,12,0)
-- We unpack the 'FastMutInt' counter as it is always consumed strictly.
{-# NOUNPACK #-} !FastMutInt
-- ^ Number of computed z-encodings for all buckets.
@@ -318,6 +319,9 @@ data FastStringTable = FastStringTable
-- in 'mkFastStringWith' and needs to be boxed any way.
-- If this is unpacked, then we box this single 'FastMutInt' once for each
-- allocated FastString.
+#else+ {-# UNPACK #-} !FastMutInt -- number of computed z-encodings for all buckets+#endif
(Array# (IORef FastStringTableSegment)) -- ^ concurrent segments
data FastStringTableSegment = FastStringTableSegment
Activity
AndreasPK commentedon Dec 2, 2025
Related HLS bug where this was discovered: haskell/haskell-language-server#4674
shayne-fletcher commentedon Dec 7, 2025
what would that cpp look like and where would it go? FastString.hs? we can have ghc-lib generate it. care to offer a patch?
vaibhavsagar commentedon Dec 19, 2025
I don't know where to put this as a PR, but I'm guessing a patch would look something like this:
shayne-fletcher commentedon Dec 21, 2025
cc @dylant-da
dylant-da commentedon Dec 22, 2025
Seen this just now - I'll take a look tomorrow to see what I can understand of the issue and the proposed fix.
AndreasPK commentedon Dec 22, 2025
What @vaibhavsagar posted seems right to me.
hasufell commentedon Jan 6, 2026
What is the status of fixing this?
dylant-da commentedon Jan 12, 2026
Apologies, this fell off my radar - taking a look at incorporating this change later today.
dylant-da commentedon Jan 13, 2026
Gonna need a bit longer to make the time for this.
vaibhavsagar commentedon Jul 6, 2026
Were you able to make any progress on this?
ysangkok commentedon Sep 12, 2026
@dylant-da Are you still planning to address this?
ysangkok commentedon Oct 20, 2026
@paulbrauner-da Are you looking for new maintainers for this library?