GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2024-02-06T15:36:16Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/14963ghci -fdefer-type-errors can't run IO action from another module2024-02-06T15:36:16Zelaforgeghci -fdefer-type-errors can't run IO action from another moduleThis is enough to trigger a crash on OS X and Linux:
Bug1.hs:
```
module Bug1.hs where
import qualified Bug2
test :: IO Bool
test = Bug2.failure
```
Bug2.hs:
```
module Bug2 where
failure :: IO Bool
failure = return False
```
Shel...This is enough to trigger a crash on OS X and Linux:
Bug1.hs:
```
module Bug1.hs where
import qualified Bug2
test :: IO Bool
test = Bug2.failure
```
Bug2.hs:
```
module Bug2 where
failure :: IO Bool
failure = return False
```
Shell:
```
% ghci -fdefer-type-errors -ignore-dot-ghci
GHCi, version 8.4.1: http://www.haskell.org/ghc/ :? for help
Prelude> :load Bug
[1 of 2] Compiling Bug2 ( Bug2.hs, interpreted )
[2 of 2] Compiling Bug ( Bug.hs, interpreted )
Ok, two modules loaded.
*Bug> test
ghc: panic! (the 'impossible' happened)
(GHC version 8.4.1 for x86_64-apple-darwin):
nameModule
system $dShow_a1LX
Call stack:
CallStack (from HasCallStack):
callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable
pprPanic, called at compiler/basicTypes/Name.hs:241:3 in ghc:Name
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
```
This is specific to 8.4.1, in 8.0.2 I get "False" as expected. If I leave off -fdefer-type-errors, it works. It also seems to be ghci only, compiling with -fdefer-type-errors doesn't have the problem.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.4.1 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"ghci -fdefer-type-errors can't run IO action from another module","status":"New","operating_system":"","component":"GHCi","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.4.1","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This is enough to trigger a crash on OS X and Linux:\r\n\r\nBug1.hs:\r\n{{{\r\nmodule Bug1.hs where\r\nimport qualified Bug2\r\n\r\ntest :: IO Bool\r\ntest = Bug2.failure\r\n}}}\r\n\r\nBug2.hs:\r\n{{{\r\nmodule Bug2 where\r\n\r\nfailure :: IO Bool\r\nfailure = return False\r\n}}}\r\n\r\nShell:\r\n{{{\r\n% ghci -fdefer-type-errors -ignore-dot-ghci\r\nGHCi, version 8.4.1: http://www.haskell.org/ghc/ :? for help\r\nPrelude> :load Bug\r\n[1 of 2] Compiling Bug2 ( Bug2.hs, interpreted )\r\n[2 of 2] Compiling Bug ( Bug.hs, interpreted )\r\nOk, two modules loaded.\r\n*Bug> test\r\nghc: panic! (the 'impossible' happened)\r\n (GHC version 8.4.1 for x86_64-apple-darwin):\r\n\tnameModule\r\n system $dShow_a1LX\r\n Call stack:\r\n CallStack (from HasCallStack):\r\n callStackDoc, called at compiler/utils/Outputable.hs:1150:37 in ghc:Outputable\r\n pprPanic, called at compiler/basicTypes/Name.hs:241:3 in ghc:Name\r\n\r\nPlease report this as a GHC bug: http://www.haskell.org/ghc/reportabug\r\n}}}\r\n\r\nThis is specific to 8.4.1, in 8.0.2 I get \"False\" as expected. If I leave off -fdefer-type-errors, it works. It also seems to be ghci only, compiling with -fdefer-type-errors doesn't have the problem.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.2https://gitlab.haskell.org/ghc/ghc/-/issues/14905GHCi segfaults with +RTS -Di after hitting a breakpoint2019-07-07T18:15:06ZÖmer Sinan AğacanGHCi segfaults with +RTS -Di after hitting a breakpointSteps to reproduce:
- Compile stage2 with `-debug`
- Run GHCi with `+RTS -Di`
- Load an interpreted module with a definition, set a breakpoint on the definition
- Evaluate the definition
GHCi crashes with a segfault. Backtrace:
```
#0...Steps to reproduce:
- Compile stage2 with `-debug`
- Run GHCi with `+RTS -Di`
- Load an interpreted module with a definition, set a breakpoint on the definition
- Evaluate the definition
GHCi crashes with a segfault. Backtrace:
```
#0 0x00007ffff18bcaa9 in disInstr (bco=0x4200013f30, pc=1) at rts/Disassembler.c:71
#1 0x00007ffff18c89e9 in interpretBCO (cap=0x7ffff19431c0 <MainCapability>) at rts/Interpreter.c:986
#2 0x00007ffff18d19fe in schedule (initialCapability=0x7ffff19431c0 <MainCapability>, task=0x7fffe0000910) at rts/Schedule.c:471
#3 0x00007ffff18d4ee2 in scheduleWorker (cap=0x7ffff19431c0 <MainCapability>, task=0x7fffe0000910) at rts/Schedule.c:2553
#4 0x00007ffff18ccab8 in workerStart (task=0x7fffe0000910) at rts/Task.c:444
#5 0x00007ffff0c3c6ba in start_thread (arg=0x7fffee9aa700) at pthread_create.c:333
#6 0x00007ffff06f241d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
```
in this line:
```
71 debugBelch(" %s\n", ((CostCentre*)(literals[instrs[pc+3]]))->label);
```
`literals[instrs[pc+3]]` is null.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.5 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | GHCi |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"GHCi segfaults with +RTS -Di after hitting a breakpoint","status":"New","operating_system":"","component":"GHCi","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.5","keywords":[],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"Steps to reproduce:\r\n\r\n- Compile stage2 with `-debug`\r\n- Run GHCi with `+RTS -Di`\r\n- Load an interpreted module with a definition, set a breakpoint on the definition\r\n- Evaluate the definition\r\n\r\nGHCi crashes with a segfault. Backtrace:\r\n\r\n{{{\r\n#0 0x00007ffff18bcaa9 in disInstr (bco=0x4200013f30, pc=1) at rts/Disassembler.c:71\r\n#1 0x00007ffff18c89e9 in interpretBCO (cap=0x7ffff19431c0 <MainCapability>) at rts/Interpreter.c:986\r\n#2 0x00007ffff18d19fe in schedule (initialCapability=0x7ffff19431c0 <MainCapability>, task=0x7fffe0000910) at rts/Schedule.c:471\r\n#3 0x00007ffff18d4ee2 in scheduleWorker (cap=0x7ffff19431c0 <MainCapability>, task=0x7fffe0000910) at rts/Schedule.c:2553\r\n#4 0x00007ffff18ccab8 in workerStart (task=0x7fffe0000910) at rts/Task.c:444\r\n#5 0x00007ffff0c3c6ba in start_thread (arg=0x7fffee9aa700) at pthread_create.c:333\r\n#6 0x00007ffff06f241d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109\r\n}}}\r\n\r\nin this line:\r\n\r\n{{{\r\n71 debugBelch(\" %s\\n\", ((CostCentre*)(literals[instrs[pc+3]]))->label);\r\n}}}\r\n\r\n`literals[instrs[pc+3]]` is null.","type_of_failure":"OtherFailure","blocking":[]} -->8.4.2https://gitlab.haskell.org/ghc/ghc/-/issues/14052Significant GHCi speed regression with :module and `let` in GHC 8.2.12021-10-07T13:16:12ZRyan ScottSignificant GHCi speed regression with :module and `let` in GHC 8.2.1I recently noticed that the performance of `doctest` in GHC 8.2.1 (see the corresponding [doctest issue](https://github.com/sol/doctest/issues/170)) can be much, much worse than in previous versions of 8.0.2. So bad, in fact, that a proj...I recently noticed that the performance of `doctest` in GHC 8.2.1 (see the corresponding [doctest issue](https://github.com/sol/doctest/issues/170)) can be much, much worse than in previous versions of 8.0.2. So bad, in fact, that a project with 865 `doctest` examples takes about three hours to complete in 8.2.1, whereas it would only take 8 seconds in 8.0.2.
To reproduce this issue in a fairly minimal way, you can use the following script to generate a file which simulates what `doctest` is doing:
```hs
-- GenExample.hs
module Main where
import Control.Monad
import System.Environment
import System.Exit
import System.IO
main :: IO ()
main = do
args <- getArgs
case args of
n:_ -> genExamples (read n)
_ -> do hPutStrLn stderr "usage: runghc GenExamples.hs <num-examples>"
exitWith $ ExitFailure 1
genExamples :: Int -> IO ()
genExamples nExamples = do
putStrLn ":l Foo"
ireplicateA_ nExamples genExample
genExample :: Int -> IO ()
genExample i = putStr $ unlines
[ ":m *Foo"
, "example : \"expr" ++ show i ++ "\""
, "let foo = it"
, "\"marker\""
, "let it = foo"
]
ireplicateA_ :: Applicative m => Int -> (Int -> m a) -> m ()
ireplicateA_ cnt0 f =
loop cnt0 0
where
loop cnt n
| cnt <= 0 = pure ()
| otherwise = f n *> (loop (cnt - 1) $! (n + 1))
```
You'll also need this file:
```hs
-- Foo.hs
module Foo where
example :: Char
example = 'a'
```
First, use `GenExample` to generate a GHCi script:
```
$ runghc GenExample.hs 500 > Example.script
```
Now you can run the script like so (using GHCi 8.0.2 as an example):
```
$ /opt/ghc/8.0.2/bin/ghci -ghci-script Example.script Foo.hs
```
With GHCi 8.0.2, this takes about three seconds. But with GHCi 8.2.1, this takes about 35 seconds!8.4.2Ömer Sinan AğacanÖmer Sinan Ağacan