Skip to content

Commit

Permalink
Sleep before running GHC configure script
Browse files Browse the repository at this point in the history
To see if manually running the configure script also triggers a segfault.

TODO: Why does a segfault now appear to happen when running `threadDelay`?

Logs:

```
[ Info  ] Detected alpine linux... setting LD=ld.bfd
WAIT
cwd: /root/.ghcup/tmp/ghcup-361d17ad/ghc-9.4.8-i386-unknown-linux
cmd: ["./configure","--prefix=/root/.ghcup/ghc/9.4.8","--disable-ld-override"]
env: Just [("LD","ld.bfd"),("GHCUP_CURL_OPTS","--silent"),("HOME","/root"),("HOSTNAME","1aaca70b41dc"),("LANG","C.UTF-8"),("NO_COLOR","1"),("OLDPWD","/"),("PATH","/root/.cabal/bin:/root/.ghcup:/root/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"),("PWD","/src"),("SHLVL","1"),("TERM","xterm"),("ghcup_datadir","/src/./.")]
2147483647
2147483647
about to sleep
Segmentation fault (core dumped)
```
  • Loading branch information
runeksvendsen committed Feb 23, 2024
1 parent d993ae5 commit 8cb52da
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions lib/GHCup/GHC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Encoding as E
import qualified Text.Megaparsec as MP
import Data.Int (Int32)


data GHCVer = SourceDist Version
Expand Down Expand Up @@ -465,11 +466,24 @@ installUnpackedGHC path inst tver forceInstall addConfArgs
pure $ Just (("LD", "ld.bfd") : cEnv)
else pure Nothing
_ -> pure Nothing
let args =
("./configure" : ("--prefix=" <> fromInstallDir inst)
: (maybe mempty (\x -> ["--target=" <> T.unpack x]) (_tvTarget tver) <> ldOverride <> (T.unpack <$> addConfArgs))
)
cwd = fromGHCupPath path
lEM $ do
logInfo $ T.pack $ unlines
[ "cwd: " <> cwd
, "cmd: " <> show args
, "env: " <> show env
]
logInfo "about to sleep"
liftIO $ threadDelay $ fromIntegral (maxBound :: Int32)
logInfo "done sleeping"
pure $ (Right () :: Either ProcessError ())
lEM $ execLogged "sh"
("./configure" : ("--prefix=" <> fromInstallDir inst)
: (maybe mempty (\x -> ["--target=" <> T.unpack x]) (_tvTarget tver) <> ldOverride <> (T.unpack <$> addConfArgs))
)
(Just $ fromGHCupPath path)
args
(Just cwd)
"ghc-configure"
env
tmpInstallDest <- lift withGHCupTmpDir
Expand Down

0 comments on commit 8cb52da

Please sign in to comment.