Segfault when using Rel8 with a mixture of object- and byte-code in GHCi
Summary
This was first reported on the rel8 issue tracker.
Users ran into a segfault when using the library in GHCi with a mixture of object code and byte code.
For context, rel8 uses HKD and generics to turn monadic Haskell code into a ByteString of SQL via the opaleye library.
Steps to reproduce
@ulidtko produced the following reproducer. Note this depends on quite a few libraries through rel8
, so it could do with some further minimization:
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DisambiguateRecordFields #-}
module Main where
import "base" Prelude
import "rel8" Rel8
test :: Insert ()
test = Insert { into=schema, rows=mempty, onConflict=DoNothing, returning=NoReturning }
where
schema :: TableSchema (Name String, Name String)
schema = TableSchema {name="test", columns=("colA","colB")}
main :: IO ()
main = crash where crash = putStrLn . showInsert $ test
-- runs normally when compiled
-- runs normally in ghci with :set -fobject-code
-- runs normally when the entire rel8 package is ghci-loaded as interpreted
-- SIGSEGV in ghci (cabal repl/stack repl/runhaskell) if interpreted + rel8 compiled
Expected behavior
No segfaults
Environment
- GHC version used: ghc-9.6.4, ghc-9.10.1
This occurs both on x86_64-linux and x86_64-darwin.