GHC issueshttps://gitlab.haskell.org/ghc/ghc/-/issues2023-11-03T12:39:28Zhttps://gitlab.haskell.org/ghc/ghc/-/issues/21490Live lock in acquire_spin_lock_slow_path2023-11-03T12:39:28ZGuillaume BouchardLive lock in acquire_spin_lock_slow_path## Summary
My program is sometime stuck, tacking CPU (100% of one capability), and making no progress.
When using `perf top`, I can observe that all the time is spent in `acquire_spin_lock_slow_path`, see ![image](/uploads/c60463add19b...## Summary
My program is sometime stuck, tacking CPU (100% of one capability), and making no progress.
When using `perf top`, I can observe that all the time is spent in `acquire_spin_lock_slow_path`, see ![image](/uploads/c60463add19b24e1ff7acc0b20b182eb/image.png)
## Steps to reproduce
Unfortunately, I cannot reproduce easilly. What I know is:
- I'm using GHC 9.2.1
- This program is complex, involve multi threading, using `-N8`
- The program uses weak reference finalizers
## Expected behavior
My program should not live lock?
## Environment
* GHC version used: 9.2.1
Optional:
* Operating System: Linux
* System Architecture: x86_64
I found this log https://gitlab.haskell.org/ghc/ghc/-/snippets/2047 posted by @bgamari which may be related, but no ticket associated. At least, if the problem is already known / fixed, this ticket will be an entrypoint for reference.Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21472Compiling ghc with `-fmax-worker-args=20` causes absentError panic.2022-07-21T02:43:12ZAndreas KlebingerCompiling ghc with `-fmax-worker-args=20` causes absentError panic.Using `stage1.*.ghc.hs.opts += -fmax-worker-args=20` and `hadrian/build -j2 -o_max20` the resulting executable panics with this error:
```
andi@horzube:~/ghc_head$ _max20/stage1/bin/ghc nofib/spectral/simple/Main.hs -O -fforce-recomp -c...Using `stage1.*.ghc.hs.opts += -fmax-worker-args=20` and `hadrian/build -j2 -o_max20` the resulting executable panics with this error:
```
andi@horzube:~/ghc_head$ _max20/stage1/bin/ghc nofib/spectral/simple/Main.hs -O -fforce-recomp -c
ghc: internal error: Oops! Entered absent arg Arg: ww
Type: Bool
In module `GHC.Tc.Utils.Monad'
(GHC version 9.5.20220502 for x86_64_unknown_linux)
Please report this as a GHC bug: https://www.haskell.org/ghc/reportabug
Aborted (core dumped)
```
Likely a bug in W/W or demand analysis.Sebastian GrafAndreas KlebingerSebastian Grafhttps://gitlab.haskell.org/ghc/ghc/-/issues/21465128-bit Callee-saved registers (Windows x64) are not saved and restored corre...2022-05-30T17:12:27ZThomas Dinsdale-Young128-bit Callee-saved registers (Windows x64) are not saved and restored correctly## Summary
The Windows x64 calling convention requires that the 128-bit registers XMM6-XMM15 be [saved (and restored) by the callee](https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170#callercallee-saved-regi...## Summary
The Windows x64 calling convention requires that the 128-bit registers XMM6-XMM15 be [saved (and restored) by the callee](https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170#callercallee-saved-registers).
`StgRunIsImplementedInAssembler`, which handles this in the runtime, does not correctly save and restore these registers, as it uses `movq` to do so, treating them as 64-bits only.
Consequently, when the registers are restored, the high-order 64-bits are zeroed.
Instead, `movaps` should probably be used, and 16 bytes reserved for each XMM register.
The consequence of this is that FFI calls to Haskell code on Windows may violate the calling convention and lead to undefined behaviour.
## Steps to reproduce
The attached files can be compiled on Windows with `ghc Main.hs reg.c`.
[Main.hs](/uploads/625555a8de865f7114397d3d81823ef6/Main.hs)
[reg.c](/uploads/1646814458605a7f87cde873b7dbd13a/reg.c)
The Haskell main function invokes a C function `test_c`, which uses inline assembly to set a value to the XMM6 register, invoke a Haskell function `helper`, and then read out the resulting value of the XMM6 register, comparing each byte to the expected (original) value.
The output of executing `Main.exe` is:
```
This is the helper function
0: 01 01
1: 02 02
2: 03 03
3: 04 04
4: 05 05
5: 06 06
6: 07 07
7: 08 08
8: 09 00
9: 0a 00
10: 0b 00
11: 0c 00
12: 0d 00
13: 0e 00
14: 0f 00
15: 10 00
Done.
```
This indicates that the lower-order 8 bytes of the register are correctly restored after the call to `helper`, but the high-order 8 bytes are not.
This is consistent with the use of `movq` instead of `movaps` (or `movups`).
## Expected behavior
The expected output is:
```
This is the helper function
0: 01 01
1: 02 02
2: 03 03
3: 04 04
4: 05 05
5: 06 06
6: 07 07
7: 08 08
8: 09 09
9: 0a 0a
10: 0b 0b
11: 0c 0c
12: 0d 0d
13: 0e 0e
14: 0f 0f
15: 10 10
Done.
```
## Environment
* GHC version used: 9.0.2, 8.10.2
Optional:
* Operating System: Windows 8.1
* System Architecture: x86-64Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21440exprIsDeadEnd is broken2022-08-05T14:49:07ZAndreas KlebingerexprIsDeadEnd is broken```
exprIsDeadEnd :: CoreExpr -> Bool
-- See Note [Bottoming expressions]
exprIsDeadEnd e
| isEmptyTy (exprType e)
= True
| otherwise
= go 0 e
where
go n (Var v) = isDeadEndId v && n >= idArity v
go n (...```
exprIsDeadEnd :: CoreExpr -> Bool
-- See Note [Bottoming expressions]
exprIsDeadEnd e
| isEmptyTy (exprType e)
= True
| otherwise
= go 0 e
where
go n (Var v) = isDeadEndId v && n >= idArity v
go n (App e a) | isTypeArg a = go n e
| otherwise = go (n+1) e
```
We have
```
failIO :: forall a. String -> IO a
[Arity = 0 -- unknown arity
, ...]
failIO = failIO1
```
We call
```
exprIsDead (App failIO msg)
=> AppCase
go 1 failIO
=> Var case
isDeadEndId failIO && 1 >= idArity failIO
=>
True && n >= 1 >= 0
=>
True
```
The problem is that we trust `idArity` to return a known arity. But it can also return zero if the arity is unknown.
That means for a potentially bottoming function we always get True for `exprIsDeadEnd` if it has unknown Arity.Andreas KlebingerAndreas Klebingerhttps://gitlab.haskell.org/ghc/ghc/-/issues/21402Alpine bindists installation breaks if the prefix contains "xxx"2022-07-28T10:12:14ZsterniAlpine bindists installation breaks if the prefix contains "xxx"## Summary
When the Alpine bindists (tested with 8.10.2 and 9.2.2) are configured to have a `--prefix` containing `xxx` anywhere in the path, the installation will fail while trying to access paths that curiously contain 3 spaces instea...## Summary
When the Alpine bindists (tested with 8.10.2 and 9.2.2) are configured to have a `--prefix` containing `xxx` anywhere in the path, the installation will fail while trying to access paths that curiously contain 3 spaces instead of `xxx`.
This is because of the following snippet from its `Makefile` where `xxx` is used to temporarily sanitize three spaces:
```
PKG_CONFS = $(shell find "$(ActualLibsDir)/package.conf.d" -name '*.conf' | sed 's: :xxx:g')
update_package_db: install_bin install_lib
@echo "$(PKG_CONFS)"
@echo "Updating the package DB"
$(foreach p, $(PKG_CONFS),\
$(call patchpackageconf,$(shell echo $(notdir $p) | sed 's/-\([0-9]*[0-9]\.\)*conf//g'),$(shell echo "$p" | sed 's:xxx: :g'),$(docdir),$(shell mk/relpath.s
h "$(ActualLibsDir)" "$(docdir)")))
'$(WrapperBinsDir)/$(CrossCompilePrefix)ghc-pkg' recache
```
## Steps to reproduce
Use an Alpine bindist for either 8.10.2 or 9.2.2 (others likely also work) and select a prefix containing `xxx` for `configure`, then install.
## Expected behavior
The installation works normally. Having `xxx` in prefix is rare, but can happen for Nix since `x` is part of the alphabet used for Nix's base32 hashes.
## Environment
* GHC version used: 9.2.2, 8.10.2
Optional:
* Operating System: NixOS
* System Architecture: x86_64-linuxBen GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21391Core Lint error when building reroute-0.6.0.0 on HEAD2023-08-21T02:06:18ZRyan ScottCore Lint error when building reroute-0.6.0.0 on HEAD_(Originally discovered in a `head.hackage` CI job [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1009813#L926).)_
The `reroute-0.6.0.0` Hackage library fails to build on HEAD when built with `-dcore-lint`. Here is a minimal ..._(Originally discovered in a `head.hackage` CI job [here](https://gitlab.haskell.org/ghc/head.hackage/-/jobs/1009813#L926).)_
The `reroute-0.6.0.0` Hackage library fails to build on HEAD when built with `-dcore-lint`. Here is a minimal example:
```hs
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE RankNTypes #-}
module Web.Routing.SafeRouting where
import Control.DeepSeq (NFData (..))
import Data.Kind (Constraint)
import Data.Typeable (Typeable)
class FromHttpApiData a where
data PolyMap (c :: * -> Constraint) (f :: * -> *) (a :: *) where
PMNil :: PolyMap c f a
PMCons :: (Typeable p, c p) => f (p -> a) -> PolyMap c f a -> PolyMap c f a
rnfHelper :: (forall p. c p => f (p -> a) -> ()) -> PolyMap c f a -> ()
rnfHelper _ PMNil = ()
rnfHelper h (PMCons v pm) = h v `seq` rnfHelper h pm
data PathMap x =
PathMap [x] (PolyMap FromHttpApiData PathMap x)
instance NFData x => NFData (PathMap x) where
rnf (PathMap a b) = rnf a `seq` rnfHelper rnf b
```
It will produce this Core Lint error on HEAD:
<details>
```
$ ~/Software/ghc/inplace/bin/ghc-stage2 -dcore-lint Bug1.hs -O -dno-typeable-binds -fforce-recomp
[1 of 1] Compiling Web.Routing.SafeRouting ( Bug1.hs, Bug1.o )
*** Core Lint errors : in result of Specialise ***
Bug1.hs:24:10: warning:
From-type of Cast differs from type of enclosed expression
From-type: NFData x_aT3
Type of enclosed expression: NFData (p_aTl -> x_aT3)
Actual enclosed expression: $dNFData_sUv
Coercion used in cast: N:NFData[0] <x_aT3>_N
In the RHS of $s$crnf_sUw :: forall {p} {x}. PathMap x -> ()
In the body of lambda with binder p_aTl :: *
In the body of lambda with binder x_aT3 :: *
In the body of lambda with binder eta_B0 :: PathMap x_aT3
In the body of letrec with binders $dNFData_sUv :: NFData
(p_aTl -> x_aT3)
In a case alternative: (PathMap a_aHg :: [x_aT3],
b_aHh :: PolyMap FromHttpApiData PathMap x_aT3)
Substitution: [TCvSubst
In scope: InScope {x_aT3 p_aTl}
Type env: [aT3 :-> x_aT3, aTl :-> p_aTl]
Co env: []]
*** Offending Program ***
Rec {
rnfHelper [Occ=LoopBreaker]
:: forall (c :: * -> Constraint) (f :: * -> *) a.
(forall p. c p => f (p -> a) -> ()) -> PolyMap c f a -> ()
[LclIdX,
Arity=2,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [60 30] 90 10}]
rnfHelper
= \ (@(c_aSx :: * -> Constraint))
(@(f_aSy :: * -> *))
(@a_aSz)
(ds_dTD :: forall p. c_aSx p => f_aSy (p -> a_aSz) -> ())
(ds_dTE :: PolyMap c_aSx f_aSy a_aSz) ->
case ds_dTE of {
PMNil -> ();
PMCons @p_aSD $dTypeable_aSE irred_aSF v_aHn pm_aHo ->
case ds_dTD @p_aSD irred_aSF v_aHn of { () ->
rnfHelper @c_aSx @f_aSy @a_aSz ds_dTD pm_aHo
}
}
end Rec }
Rec {
$s$crnf_sUw :: forall {p} {x}. PathMap x -> ()
[LclId, Arity=1]
$s$crnf_sUw
= \ (@p_aTl) (@x_aT3) (eta_B0 :: PathMap x_aT3) ->
let {
$dNFData_sUv :: NFData (p_aTl -> x_aT3)
[LclId,
Unf=Unf{Src=<vanilla>, TopLvl=False, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [] 20 60}]
$dNFData_sUv
= (\ (v_aUr :: p_aTl -> x_aT3) ->
case v_aUr of { __DEFAULT -> () })
`cast` (Sym (N:NFData[0] <p_aTl -> x_aT3>_N)
:: ((p_aTl -> x_aT3) -> ()) ~R# NFData (p_aTl -> x_aT3)) } in
case eta_B0 of { PathMap a_aHg b_aHh ->
case $fNFData1List_$cliftRnf
@x_aT3
($dNFData_sUv
`cast` (N:NFData[0] <x_aT3>_N :: NFData x_aT3 ~R# (x_aT3 -> ())))
a_aHg
of
{ () ->
rnfHelper
@FromHttpApiData
@PathMap
@x_aT3
(\ (@p_X3) _ [Occ=Dead] (eta_X4 :: PathMap (p_X3 -> x_aT3)) ->
$crnf_aT6
@(p_X3 -> x_aT3)
((\ (v_aUr :: p_X3 -> x_aT3) -> case v_aUr of { __DEFAULT -> () })
`cast` (Sym (N:NFData[0] <p_X3 -> x_aT3>_N)
:: ((p_X3 -> x_aT3) -> ()) ~R# NFData (p_X3 -> x_aT3)))
eta_X4)
b_aHh
}
}
$crnf_aT6 [Occ=LoopBreaker]
:: forall x. NFData x => PathMap x -> ()
[LclId,
Arity=2,
Unf=Unf{Src=<vanilla>, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True, Guidance=IF_ARGS [0 20] 150 0},
RULES: "SPEC $crnf @(p -> x)"
forall (@p_aTl) (@x_aT3) ($dNFData_sUv :: NFData (p_aTl -> x_aT3)).
$crnf_aT6 @(p_aTl -> x_aT3) $dNFData_sUv
= $s$crnf_sUw @p_aTl @x_aT3]
$crnf_aT6
= \ (@x_aT3)
($dNFData_aT4 :: NFData x_aT3)
(eta_B0 :: PathMap x_aT3) ->
case eta_B0 of { PathMap a_aHg b_aHh ->
case $fNFData1List_$cliftRnf
@x_aT3
($dNFData_aT4
`cast` (N:NFData[0] <x_aT3>_N :: NFData x_aT3 ~R# (x_aT3 -> ())))
a_aHg
of
{ () ->
rnfHelper
@FromHttpApiData
@PathMap
@x_aT3
(\ (@p_aTl) _ [Occ=Dead] (eta_X3 :: PathMap (p_aTl -> x_aT3)) ->
$crnf_aT6
@(p_aTl -> x_aT3)
((\ (v_aUr :: p_aTl -> x_aT3) -> case v_aUr of { __DEFAULT -> () })
`cast` (Sym (N:NFData[0] <p_aTl -> x_aT3>_N)
:: ((p_aTl -> x_aT3) -> ()) ~R# NFData (p_aTl -> x_aT3)))
eta_X3)
b_aHh
}
}
end Rec }
$fNFDataPathMap [InlPrag=INLINE (sat-args=0)]
:: forall x. NFData x => NFData (PathMap x)
[LclIdX[DFunId(nt)],
Arity=2,
Unf=Unf{Src=InlineStable, TopLvl=True, Value=True, ConLike=True,
WorkFree=True, Expandable=True,
Guidance=ALWAYS_IF(arity=1,unsat_ok=False,boring_ok=True)
Tmpl= $crnf_aT6
`cast` (forall (x :: <*>_N).
<NFData x>_R %<'Many>_N ->_R Sym (N:NFData[0] <PathMap x>_N)
:: (forall {x}. NFData x => PathMap x -> ())
~R# (forall {x}. NFData x => NFData (PathMap x)))}]
$fNFDataPathMap
= $crnf_aT6
`cast` (forall (x :: <*>_N).
<NFData x>_R %<'Many>_N ->_R Sym (N:NFData[0] <PathMap x>_N)
:: (forall {x}. NFData x => PathMap x -> ())
~R# (forall {x}. NFData x => NFData (PathMap x)))
*** End of Offense ***
<no location info>: error:
Compilation had errors
<no location info>: error: ExitFailure 1
```
</details>
This regression was introduced in commit 4d2ee313f23a4454d12c9f94ff132f078dd64d31 (`Specialising through specialised method calls`). cc @sgraf8129.6.1Simon Peyton JonesRyan ScottSimon Peyton Joneshttps://gitlab.haskell.org/ghc/ghc/-/issues/21390Segfault in GHC running check-exact2022-04-25T15:22:11ZAlan ZimmermanSegfault in GHC running check-exactThis is a marker for a segfault I am seeing on my ghc-exactprint update, which I have captured in branch wip/az/T21355-exactprint-update-segfault
Demonstrates segfault in ghci
In the utils/check-exact directory do
...This is a marker for a segfault I am seeing on my ghc-exactprint update, which I have captured in branch wip/az/T21355-exactprint-update-segfault
Demonstrates segfault in ghci
In the utils/check-exact directory do
../../_build/stage1/bin/ghc --interactive
:l Main.hs
:main
It segfaults.
Do
../../_build/stage1/bin/ghc --interactive
:set -fobject-code
:l Main.hs
:main
It runs successfully (logging a lot of stuff).
The two logs are different, the one just before the segfault returns
junk for an AddEpAnn value.
See https://gist.github.com/alanz/9b944a59dbaa04f5d502fb5244d83270
for some detail
It is from a work in progress branch, and needs to be distilled to something useful.
But I have a workaround by using -fobject-code so will proceed that way for a little longer.
And will revisit some time, if no-one else does.9.4.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21358Using set -e in .gitlab/ci.sh doesn't work as intended2022-05-30T13:41:47ZMatthew PickeringUsing set -e in .gitlab/ci.sh doesn't work as intendedIf you check the CI log you will find this section of the log from `test_hadrian`:
```
=====> 2 of 2 [0, 0, 0]
=====> 2 of 2 [0, 0, 0]
Compile failed (exit code 127) errors were:
/bin/sh: 1: /builds/ghc/ghc/_build/stage1-test/bin/ghc: n...If you check the CI log you will find this section of the log from `test_hadrian`:
```
=====> 2 of 2 [0, 0, 0]
=====> 2 of 2 [0, 0, 0]
Compile failed (exit code 127) errors were:
/bin/sh: 1: /builds/ghc/ghc/_build/stage1-test/bin/ghc: not found
*** unexpected failure for T2632(normal)
Compile failed (exit code 127) errors were:
/bin/sh: 1: /builds/ghc/ghc/_build/stage1-test/bin/ghc: not found
*** unexpected failure for T13609(normal)
Performance Metrics (test environment: x86_64-linux-deb10-perf):
None collected.
Unexpected results from:
TEST="T13609 T2632"
SUMMARY for test run started at Wed Apr 6 18:01:47 2022
0:00:00.017100 spent to go through
2 total tests, which gave rise to
8 test cases, of which
6 were skipped
0 had missing libraries
0 expected passes
0 expected failures
0 caused framework failures
0 caused framework warnings
0 unexpected passes
2 unexpected failures
0 unexpected stat failures
0 fragile tests
Unexpected failures:
/builds/ghc/ghc/tmp/ghctest-hxd2n5g5/test spaces/testsuite/tests/stage1/T13609.run T13609 [exit code non-0] (normal)
/builds/ghc/ghc/tmp/ghctest-hxd2n5g5/test spaces/testsuite/tests/stage1/T2632.run T2632 [exit code non-0] (normal)
Appending 0 stats to file: /builds/ghc/ghc/performance-metrics.tsv
user error (tests failed)
Build failed.
�[0;31mhadrian/build-cabal --flavour=perf -j8 --broken-test= --bignum=gmp test --test-root-dirs=testsuite/tests/stage1 --test-compiler=stage1 runtest.opts+=--ignore-perf-failures=all failed�[0m
�[1;34mRunning *@...�[0m
/builds/ghc/ghc/.gitlab/common.sh: line 48: *@: command not found
�[0;31m*@ failed�[0m
�[1;34mRunning *@...�[0m
/builds/ghc/ghc/.gitlab/common.sh: line 48: *@: command not found
�[0;31m*@ failed�[0m
[1 of 2] Compiling Main ( proftest.hs, proftest.o )
[2 of 2] Linking proftest
�[1;34mRunning hadrian/build-cabal --flavour=perf -j8 --broken-test= --bignum=gmp test --summary-junit=./junit.xml --test-have-intree-files --test-compiler=/builds/ghc/ghc/_build/install/bin/ghc runtest.opts+=--ignore-perf-failures=all...�[0m
```
What is happening here:
1. We run the stage1 tests which fail (#21072)
2. There is this error /builds/ghc/ghc/.gitlab/common.sh: line 48: *@: command not found, which is caused by a bug in the `shell` function.
So three different commands fail here but are not caught by set -e, the solution appears to be add explicit error handling to the commands which may fail. (http://mywiki.wooledge.org/BashFAQ/105)9.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/21352centos7 fails to build text2022-06-22T10:24:42ZMatthew Pickeringcentos7 fails to build textSee; https://gitlab.haskell.org/ghc/ghc/-/jobs/1001132
```
Command line: /opt/ghc/8.10.7/bin/ghc -Wall -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-env -' '-package-db _build/stage0/lib/package.co...See; https://gitlab.haskell.org/ghc/ghc/-/jobs/1001132
```
Command line: /opt/ghc/8.10.7/bin/ghc -Wall -hisuf hi -osuf o -hcsuf hc -static -hide-all-packages -no-user-package-db '-package-env -' '-package-db _build/stage0/lib/package.conf.d' '-this-unit-id text-2.0' '-package-id array-0.5.4.0' '-package-id base-4.14.3.0' '-package-id binary-0.8.8.0' '-package-id bytestring-0.10.12.0' '-package-id deepseq-1.4.4.0' '-package-id ghc-prim-0.6.1' '-package-id template-haskell-2.18.0.0' -i -i/builds/ghc/ghc/_build/stage0/libraries/text/build -i/builds/ghc/ghc/_build/stage0/libraries/text/build/autogen -i/builds/ghc/ghc/libraries/text/src -I_build/stage0/libraries/text/build -I/opt/ghc/8.10.7/lib/ghc-8.10.7/bytestring-0.10.12.0/include -I/opt/ghc/8.10.7/lib/ghc-8.10.7/base-4.14.3.0/include -I/opt/ghc/8.10.7/lib/ghc-8.10.7/integer-gmp-1.0.3.0/include -I/opt/ghc/8.10.7/lib/ghc-8.10.7/include -optP-include -optP_build/stage0/libraries/text/build/autogen/cabal_macros.h -optc-std=gnu99 -optP-std=gnu99 -outputdir _build/stage0/libraries/text/build -optc-std=gnu99 -optc-I_build/stage0/libraries/text/build -optc-I/opt/ghc/8.10.7/lib/ghc-8.10.7/bytestring-0.10.12.0/include -optc-I/opt/ghc/8.10.7/lib/ghc-8.10.7/base-4.14.3.0/include -optc-I/opt/ghc/8.10.7/lib/ghc-8.10.7/integer-gmp-1.0.3.0/include -optc-I/opt/ghc/8.10.7/lib/ghc-8.10.7/include -optc-Wno-error=inline -optP-Wno-nonportable-include-path -c libraries/text/cbits/measure_off.c -o _build/stage0/libraries/text/build/c/cbits/measure_off.o -O0 -H64m -Wall -fwarn-tabs -funbox-strict-fields -O2 -XHaskell2010 -XNondecreasingIndentation -O -dcore-lint -dno-debug-output -fno-warn-deprecated-flags
===> Command failed with error code: 1
libraries/text/cbits/measure_off.c:17:23: error:
fatal error: stdatomic.h: No such file or directory
#include <stdatomic.h>
^
|
17 | #include <stdatomic.h>
| ^
compilation terminated.
`gcc' failed in phase `C Compiler'. (Exit code: 1)
```
cc @Bodigrim9.4.1Andreas KlebingerAndreas Klebingerhttps://gitlab.haskell.org/ghc/ghc/-/issues/21319HEAD fails to compile futhark-0.21.8 after "Kill derived constraints" patch2022-04-25T16:43:06ZRyan ScottHEAD fails to compile futhark-0.21.8 after "Kill derived constraints" patchAfter commit a599abba, GHC HEAD is no longer able to compile the `futhark-0.21.8` library on Hackage. Here is a minimized example of the problem:
```hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
ty...After commit a599abba, GHC HEAD is no longer able to compile the `futhark-0.21.8` library on Hackage. Here is a minimized example of the problem:
```hs
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
type family F x
f :: (F a ~ Maybe a, Show (F a)) => a -> IO ()
f _ = pure ()
g :: (F a ~ Maybe a, Show (F a)) => a -> IO ()
g = go
where
go = f
```
While GHC 9.2 and earlier are able to compile this, HEAD rejects it with:
```
$ ~/Software/ghc-9.3.20220328/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o ) [Source file changed]
Bug.hs:13:10: error:
• Could not deduce (Show a) arising from a use of ‘f’
from the context: (F a ~ Maybe a, Show (F a))
bound by the type signature for:
g :: forall a. (F a ~ Maybe a, Show (F a)) => a -> IO ()
at Bug.hs:10:1-46
Possible fix:
add (Show a) to the context of
the type signature for:
g :: forall a. (F a ~ Maybe a, Show (F a)) => a -> IO ()
• In the expression: f
In an equation for ‘go’: go = f
In an equation for ‘g’:
g = go
where
go = f
|
13 | go = f
| ^
```
The release notes entries in a599abba didn't appear to mention this kind of program behavior changing, so I thought it best to file a GHC issue about this. @rae, should this be expected to work?9.4.1Richard Eisenbergrae@richarde.devsheafsam.derbyshire@gmail.comRichard Eisenbergrae@richarde.devhttps://gitlab.haskell.org/ghc/ghc/-/issues/21265winery-1.3.2 panics on HEAD (expectJust isRecDataCon:go_tc_app)2022-03-26T17:38:23ZRyan Scottwinery-1.3.2 panics on HEAD (expectJust isRecDataCon:go_tc_app)_(Originally discovered in a `head.hackage` build [here](https://gitlab.haskell.org/RyanGlScott/head.hackage/-/jobs/983508#L4976).)_
The `winery-1.3.2` library on Hackage panics when compiled with GHC HEAD at commit bb779b90bb093274ccf7..._(Originally discovered in a `head.hackage` build [here](https://gitlab.haskell.org/RyanGlScott/head.hackage/-/jobs/983508#L4976).)_
The `winery-1.3.2` library on Hackage panics when compiled with GHC HEAD at commit bb779b90bb093274ccf7a8e5b19f6661f4925bde. Here is a minimized example:
```hs
{-# LANGUAGE RankNTypes #-}
module Codec.Winery.Class (extractorProduct') where
class GSerialiseProduct f where
dummy :: f x -> ()
productExtractor :: TransFusion [] ((->) Bool) (f Int)
extractorProduct' :: GSerialiseProduct f => Maybe (f Int)
extractorProduct' = unTransFusion productExtractor go
go :: f x -> Maybe (g x)
go _ = Nothing
newtype TransFusion f g a = TransFusion { unTransFusion :: forall h. Applicative h => (forall x. f x -> h (g x)) -> h a }
```
```
$ ~/Software/ghc-9.3.20220316/bin/ghc Bug.hs -O -fforce-recomp
[1 of 1] Compiling Codec.Winery.Class ( Bug.hs, Bug.o )
<no location info>: error:
expectJust isRecDataCon:go_tc_app
CallStack (from HasCallStack):
error, called at compiler/GHC/Data/Maybe.hs:71:27 in ghc:GHC.Data.Maybe
expectJust, called at compiler/GHC/Core/Opt/WorkWrap/Utils.hs:1348:25 in ghc:GHC.Core.Opt.WorkWrap.Utils
```
This regression was introduced in commit 8ff32124c8cd37050f3dc7cbb32b8d41711ebcaf (`DmdAnal: Don't unbox recursive data types`). cc @sgraf8129.4.1Sebastian GrafSebastian Grafhttps://gitlab.haskell.org/ghc/ghc/-/issues/21251Compact regions with sharing can lose pointer tags.2022-03-20T03:26:06ZAndreas KlebingerCompact regions with sharing can lose pointer tags.This caused https://gitlab.haskell.org/ghc/ghc/-/issues/21189
This issue is as follows. We create a compact region with some values.
We add a constructor with strict fields, where the fields reference values *already* in the compact re...This caused https://gitlab.haskell.org/ghc/ghc/-/issues/21189
This issue is as follows. We create a compact region with some values.
We add a constructor with strict fields, where the fields reference values *already* in the compact region.
This (eventually) results in a call to `stg_compactAddWorkerzh` in order to compact the closures the constructor fields point to, with this particular snippet being executed.
```
// Everything else we should copy and evaluate the components:
case
CONSTR,
CONSTR_1_0,
CONSTR_2_0,
CONSTR_1_1: {
(should) = ccall shouldCompact(compact "ptr", p "ptr");
if (should == SHOULDCOMPACT_IN_CNF) { P_[pp] = p; return(); }
```
pp is the address to store the result in. `p` is the *untagged* pointer. The fix is simple. Use `tag | p` instead of `p` (as this code already does in other places!).
I will put up a patch shortly.
This caused https://gitlab.haskell.org/ghc/ghc/-/issues/211899.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/21229Inlining DFuns leads to an unsound interaction with Specialise2023-09-13T12:07:03ZSebastian GrafInlining DFuns leads to an unsound interaction with Specialise!7599 unveiled a bug in the Specialiser.
* See also #21328
* Test is in `simplCore/should_run/T21229`
Back to the Specialiser. Consider
```hs
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE AllowA...!7599 unveiled a bug in the Specialiser.
* See also #21328
* Test is in `simplCore/should_run/T21229`
Back to the Specialiser. Consider
```hs
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE KindSignatures #-}
data B = T | F deriving Show
class Sing (b :: B) where sing :: B
instance Sing 'T where sing = T
instance Sing 'F where sing = F
f :: forall a. Sing a => Int -> (Int -> B -> B) -> B
f 0 g = g 0 (sing @a)
f n g = f @a (n-1) g
h :: forall a. Sing a => Int -> (Int -> B -> B) -> B
h = case sing @a of
T -> f @'T
F -> f @a
{-# NOINLINE h #-}
main = print $ h @'T 0 (\ _ a -> a)
```
With -O0, this prints `T`, as expected, because `h` will ultimately call its supplied argument once with `T`.
But with -O, I get `F`. Why is that? The reason is we ultimately get the following specialisation for the second call to `f`:
```
RULES: "SPEC f @a"
forall (@(a_aXu :: B)) ($dSing_s1OW :: Sing a_aXu).
f @a_aXu $dSing_s1OW
= $sf_s1OX @a_aXu]
```
and this specialisation (for when `$dSing_s1OW` is `F`) somehow also applies at `f @'T`.
FTR, here is the output of the `pprTrace "spec_call"` in Specialise:
```
spec_call
call info: CI{SpecType a_aXu
SpecDict F `cast` (Sym (N:Sing[0] <a_aXu>_N) :: B ~R# Sing a_aXu)}
useful: True
rule_bndrs: [a_aXu, $dSing_s1OW]
lhs_args: [TYPE: a_aXu, $dSing_s1OW]
spec_bndrs: [a_aXu]
spec_args: [TYPE: a_aXu,
F `cast` (Sym (N:Sing[0] <a_aXu>_N) :: B ~R# Sing a_aXu)]
dx_binds: []
rhs_env2: <InScope = {main g_aC8 a_aXu $cshowsPrec_aY5 $cshow_aYd
$cshowList_aYl $krep_aZ1 $krep_aZ2 $krep_aZ3 $krep_aZ4 $krep_aZ5
$krep_aZ6 ds_dZX main $fShowB $fSingF F $fSingT $tc'C:Sing
$trModule $tc'F $tc'T $tcB $tcSing f h main_s19F main_s19G
main_s1OF $trModule_s1OG $trModule_s1OH $trModule_s1OI
$trModule_s1OJ $krep_s1OK $tcB_s1OL $tcB_s1OM $tc'T_s1ON $tc'T_s1OO
$tc'F_s1OP $tc'F_s1OQ $tcSing_s1OR $tcSing_s1OS $krep_s1OT
$tc'C:Sing_s1OU $tc'C:Sing_s1OV}
IdSubst = [aKV :-> F
`cast` (Sym (N:Sing[0] <a_aXu>_N) :: B ~R# Sing a_aXu)]
TvSubst = [aKU :-> a_aXu]
CvSubst = []>
[]
```
How did it come to this?! For that we have to look at the Core of `h` that Specialise sees:
```
h = \ (@(a_aWY :: B))
($dSing_aWZ :: Sing a_aWY)
(eta_B0 :: Int)
(eta_B1 :: Int -> B -> B) ->
case $dSing_aWZ
`cast` (Main.N:Sing[0] <a_aWY>_N :: Sing a_aWY ~R# B)
of {
T ->
f @'T
(Main.T `cast` (Sym (Main.N:Sing[0] <'T>_N) :: B ~R# Sing 'T))
eta_B0
eta_B1;
F ->
f @a_aWY
(Main.F
`cast` (Sym (Main.N:Sing[0] <a_aWY>_N) :: B ~R# Sing a_aWY))
eta_B0
eta_B1
}
```
Note the second call to `f`. The type argument `a_aWY` is passed, as well as `Main.F` as the dictionary. That's strange! We should know *statically* that `a_aWY` must be `F`. (In fact, ``Main.F `cast` (Sym (Main.N:Sing[0] <a_aWY>_N) :: B ~R# Sing a_aWY)`` is unsound if `a_aWY` is instantiated to `T`, which would perhaps happen if we floated that expression out of the `F` case. I guess it doesn't matter much, at least not to this ticket.)
How did we get this code? After desugaring, we still have
```
h = \ (@(a_aXu :: B)) ($dSing_aXv :: Sing a_aXu) ->
case sing @a_aXu $dSing_aXv of {
T -> f @'T Main.$fSingT;
F -> f @a_aXu $dSing_aXv
}
```
But then gentle simplification inlines `sing` and sees that `$dSing_aXv` is `F` in the `F` case, performs a binder swap and successively inlines `F` (at least that's what I believe the Simplifier does).
Then the Specialiser can't connect `F` to the arguments `$dSing_aXv` or the type arg `a` and somehow bogs up. I suspect this happens in `specHeader`, but actually I'm not completely sure.
I couldn't reproduce with GHC 9.2 and any prior release. I see that we get the same Core pre-Specialise, but it is handled soundly there and we only get a specialisation for `T`. So perhaps we want to fix this before 9.4.9.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/21219Network issues with zw3rk linux runners lead to jobs taking 3x as long as before2022-03-11T12:39:30ZMatthew PickeringNetwork issues with zw3rk linux runners lead to jobs taking 3x as long as beforeA recent change seems to have made the download speed on the zw3rk runner fleet very slow so it takes nearly 2 hours to download and build the hadrian dependencies. This makes normal validate builds take upwards of 2 hours, which greatly...A recent change seems to have made the download speed on the zw3rk runner fleet very slow so it takes nearly 2 hours to download and build the hadrian dependencies. This makes normal validate builds take upwards of 2 hours, which greatly lengthens the CI pipeline time.Moritz AngermannMoritz Angermannhttps://gitlab.haskell.org/ghc/ghc/-/issues/21189Agda fails to install on HEAD2022-03-19T20:50:18ZRyan ScottAgda fails to install on HEAD_(Continuing a discussion at ghc/head.hackage!210.)_
Currently, `Agda` fails to install properly when built with GHC HEAD using `head.hackage` patches. The error arises when trying to run `Agda`'s custom `Setup.hs` script during the cop..._(Continuing a discussion at ghc/head.hackage!210.)_
Currently, `Agda` fails to install properly when built with GHC HEAD using `head.hackage` patches. The error arises when trying to run `Agda`'s custom `Setup.hs` script during the copy phase. When building `Agda-2.6.1.3`, it will fail with this error, as seen [here](https://gitlab.haskell.org/ghc/head.hackage/-/merge_requests/210#note_413083):
```
Could not parse the application primCharToNat a ≡ primCharToNat b
Operators used in the grammar:
≡ (infix operator, level 4) [_≡_ (/builds/ghc/head.hackage/ci/run/test-Agda-2.6.1.3/dist-newstyle/tmp/src-11665/Agda-2.6.1.3/src/data/lib/prim/Agda/Builtin/Equality.agda:7,6-9)]
when scope checking primCharToNat a ≡ primCharToNat b
Error: Failed to typecheck /builds/ghc/head.hackage/ci/run/test-Agda-2.6.1.3/dist-newstyle/tmp/src-11665/Agda-2.6.1.3/src/data/lib/prim/Agda/Builtin/Char/Properties.agda!
Generating Agda library interface files...
... /builds/ghc/head.hackage/ci/run/test-Agda-2.6.1.3/dist-newstyle/tmp/src-11665/Agda-2.6.1.3/src/data/lib/prim/Agda/Builtin/Bool.agda
... /builds/ghc/head.hackage/ci/run/test-Agda-2.6.1.3/dist-newstyle/tmp/src-11665/Agda-2.6.1.3/src/data/lib/prim/Agda/Builtin/Char.agda
... /builds/ghc/head.hackage/ci/run/test-Agda-2.6.1.3/dist-newstyle/tmp/src-11665/Agda-2.6.1.3/src/data/lib/prim/Agda/Builtin/Char/Properties.agda
cabal: Failed to build Agda-2.6.1.3 (which is required by test-Agda-1.0). See
the build log above for details.
```
And when building `Agda-2.6.2.1`, the most recent Hackage release, it will fail with this error, as seen [here](https://gitlab.haskell.org/ghc/head.hackage/-/merge_requests/210#note_413249):
```
Importing module Agda.Builtin.Bool not using the --no-subtyping
flag from a module which does.
Error: Failed to typecheck /builds/ghc/head.hackage/ci/run/test-Agda-2.6.2.1/dist-newstyle/tmp/src-11770/Agda-2.6.2.1/src/data/lib/prim/Agda/Builtin/Bool.agda!
Generating Agda library interface files...
... /builds/ghc/head.hackage/ci/run/test-Agda-2.6.2.1/dist-newstyle/tmp/src-11770/Agda-2.6.2.1/src/data/lib/prim/Agda/Builtin/Bool.agda
cabal: Failed to build Agda-2.6.2.1 (which is required by test-Agda-1.0). See
the build log above for details.
```
Unfortunately, I have not yet figured out a way to minimize the issue yet. The only way I know how to reproduce the issue is:
1. Set up `head.hackage`.
2. Run:
```
$ head.hackage/scripts/patch-tool unpack-patch Agda <AGDA_VER>
```
where `<AGDA_VER>` is one of `2.6.1.3` or `2.6.2.1`.
3. `cabal build Agda`
4. Run:
```
Agda_datadir=<PREFIX>/packages/Agda-<AGDA_VER>/src/data <PREFIX>/dist-newstyle/build/x86_64-linux/ghc-<GHC_VER>/Agda-<AGDA_VER>/build/agda/agda --no-libraries --local-interfaces -Werror <PREFIX>/packages/Agda-<AGDA_VER>/src/data/lib/prim/Agda/Builtin/Char/Properties.agda -v0
```
where `<PREFIX>` is the directory where you checked out `head.hackage`, `<GHC_VER>` is the version of HEAD you're using, and `<AGDA_VER>` is the same as in step (2).
Some notes:
* Bisecting reveals that commit 0e93023eef174262310737004d398bc7a606939a (`Tag inference work.`) is the culprit.
* In the case of `Agda-2.6.2.1`, the issue seems to involve roundtripping through interface files. Despite the error message given above, `Agda.Builtin.Bool` does in fact enable `--no-subtyping`. In fact, when `Agda` first parses this module, it correctly recognizes the presence of `--no-subtyping`. It's only after `Agda` writes `Agda.Builtin.Bool` to an interface file and reads it back that `Agda` mistakenly believes that `Agda.Builtin.Bool` does not enable `--no-subtyping`.
When `Agda` serializes a module to an interface file, it uses the `zlib` library to do so. Independently of this bug, I discovered that `zlib`'s test suite segfaults on HEAD—see #21186. However, that issue predates the `Tag inference work.` commit (see https://gitlab.haskell.org/ghc/ghc/-/issues/21186#note_413308), so that may just be a coincidence.
I'm opening this issue as a reminder to continue minimizing the `Agda` failure into something more tractable. For the time being, I'll mark `Agda` as being allowed to fail on the HEAD CI job.9.4.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21186zlib test suite segfaults on HEAD2022-03-18T09:20:45ZRyan Scottzlib test suite segfaults on HEADTo reproduce, run:
```
$ git clone https://github.com/haskell/zlib && cd zlib/
$ cabal run test:tests -w ~/Software/ghc-9.3.20220302/bin/ghc
Resolving dependencies...
Up to date
zlib tests
property tests
decompress . compress = id...To reproduce, run:
```
$ git clone https://github.com/haskell/zlib && cd zlib/
$ cabal run test:tests -w ~/Software/ghc-9.3.20220302/bin/ghc
Resolving dependencies...
Up to date
zlib tests
property tests
decompress . compress = id (standard): OK (0.43s)
+++ OK, passed 100 tests; 124 discarded.
decompress . compress = id (Zlib -> GZipOrZLib): OK (0.37s)
+++ OK, passed 100 tests; 140 discarded.
decompress . compress = id (GZip -> GZipOrZlib): OK (0.34s)
+++ OK, passed 100 tests; 64 discarded.
concatenated gzip members: OK (0.36s)
+++ OK, passed 100 tests; 88 discarded.
multiple gzip members, boundaries (all 2-chunks): OK (0.02s)
+++ OK, passed 100 tests.
multiple gzip members, boundaries (all 3-chunks): Segmentation fault (core dumped)
```
I haven't had an opportunity to minimize the issue, but for the time being, all of the dependencies build on HEAD.9.4.1Ben GamariBen Gamarihttps://gitlab.haskell.org/ghc/ghc/-/issues/21185Derived Generic1 instance for GADT no longer compiles on HEAD2022-10-14T21:10:30ZRyan ScottDerived Generic1 instance for GADT no longer compiles on HEADThis code compiles on GHC 9.2 and earlier:
```hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
import Data.Kind
import GHC.Generics
data family DF (a :: Type)
data instance DF (b ...This code compiles on GHC 9.2 and earlier:
```hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeFamilies #-}
module Bug where
import Data.Kind
import GHC.Generics
data family DF (a :: Type)
data instance DF (b :: Type) where
MkDF :: c -> DF c
deriving Generic1
```
However, it fails with HEAD:
```
$ ~/Software/ghc-9.3.20220302/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:10:15: error:
• Couldn't match type ‘Par1’ with ‘K1 R c’
Expected: Rep1 DF a
Actual: M1
D
('MetaData "DF" "Bug" "main" 'False)
(M1
C
('MetaCons "MkDF" 'PrefixI 'False)
(M1
S
('MetaSel
'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
Par1))
a
• In the expression: M1 (case x of MkDF g1 -> M1 (M1 (Par1 g1)))
In an equation for ‘from1’:
from1 x = M1 (case x of MkDF g1 -> M1 (M1 (Par1 g1)))
When typechecking the code for ‘from1’
in a derived instance for ‘Generic1 DF’:
To see the code I am typechecking, use -ddump-deriv
In the instance declaration for ‘Generic1 DF’
|
10 | data instance DF (b :: Type) where
| ^
Bug.hs:10:15: error:
• Couldn't match type ‘Par1’ with ‘K1 R c’
Expected: Rep1 DF a
Actual: M1
D
('MetaData "DF" "Bug" "main" 'False)
(M1
C
('MetaCons "MkDF" 'PrefixI 'False)
(M1
S
('MetaSel
'Nothing 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy)
Par1))
a
• In the pattern: M1 x
In an equation for ‘to1’:
to1 (M1 x) = case x of (M1 (M1 g1)) -> MkDF (unPar1 g1)
When typechecking the code for ‘to1’
in a derived instance for ‘Generic1 DF’:
To see the code I am typechecking, use -ddump-deriv
In the instance declaration for ‘Generic1 DF’
|
10 | data instance DF (b :: Type) where
| ^
```
The `-ddump-deriv` output contains a clue as to why:
```
$ ~/Software/ghc-9.3.20220302/bin/ghc Bug.hs -ddump-deriv
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
==================== Derived instances ====================
Derived class instances:
instance GHC.Generics.Generic1 Bug.DF where
GHC.Generics.from1 x_a1EC
= GHC.Generics.M1
(case x_a1EC of
Bug.MkDF g1_a1ED
-> GHC.Generics.M1 (GHC.Generics.M1 (GHC.Generics.Par1 g1_a1ED)))
GHC.Generics.to1 (GHC.Generics.M1 x_a1EE)
= case x_a1EE of
(GHC.Generics.M1 (GHC.Generics.M1 g1_a1EF))
-> Bug.MkDF (GHC.Generics.unPar1 g1_a1EF)
Derived type family instances:
type GHC.Generics.Rep1 Bug.DF = GHC.Generics.D1
('GHC.Generics.MetaData "DF" "Bug" "main" 'GHC.Types.False)
(GHC.Generics.C1
('GHC.Generics.MetaCons
"MkDF" 'GHC.Generics.PrefixI 'GHC.Types.False)
(GHC.Generics.S1
('GHC.Generics.MetaSel
'GHC.Maybe.Nothing
'GHC.Generics.NoSourceUnpackedness
'GHC.Generics.NoSourceStrictness
'GHC.Generics.DecidedLazy)
(GHC.Generics.Rec0 c_a101)))
```
The `Rep1` instance is using `Rec0`, even though it should actually be using `Par1`. If I had to guess what patch is responsible for the regression, I would bet on it being !6976. I'll take a look.9.4.1Ryan ScottRyan Scotthttps://gitlab.haskell.org/ghc/ghc/-/issues/21155NativeAmd64Asm: ld.lld: error: can't create dynamic relocation R_X86_64_64 ag...2022-03-26T17:38:23ZGreg SteuckNativeAmd64Asm: ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segmentI suspect something in the recent adjustors work by @bgamari went sideways. At least my usual HEAD-building OpenBSD recipe started failing with:
```
"rm" -f rts/dist-install/build/libHSrts-ghc9.3.20220301.so
"inplace/bin/ghc-stage1" -th...I suspect something in the recent adjustors work by @bgamari went sideways. At least my usual HEAD-building OpenBSD recipe started failing with:
```
"rm" -f rts/dist-install/build/libHSrts-ghc9.3.20220301.so
"inplace/bin/ghc-stage1" -this-unit-id rts -shared -dynamic -dynload deploy -no-auto-link-packages `cat rts/dist-install/libs.depend` rts/dist-install/build/Adjustor.dyn_o rts/dist-install/build/Arena.dyn_o rts/dist-install/build/Capability.dyn_o rts/dist-install/build/CheckUnload.dyn_o rts/dist-install/build/CloneStack.dyn_o rts/dist-install/build/ClosureFlags.dyn_o rts/dist-install/build/ClosureSize.dyn_o rts/dist-install/build/Disassembler.dyn_o rts/dist-install/build/ExecPage.dyn_o rts/dist-install/build/FileLock.dyn_o rts/dist-install/build/ForeignExports.dyn_o rts/dist-install/build/Globals.dyn_o rts/dist-install/build/Hash.dyn_o rts/dist-install/build/Heap.dyn_o rts/dist-install/build/Hpc.dyn_o rts/dist-install/build/HsFFI.dyn_o rts/dist-install/build/IOManager.dyn_o rts/dist-install/build/IPE.dyn_o rts/dist-install/build/Inlines.dyn_o rts/dist-install/build/Interpreter.dyn_o rts/dist-install/build/LdvProfile.dyn_o rts/dist-install/build/Libdw.dyn_o rts/dist-install/build/LibdwPool.dyn_o rts/dist-install/build/Linker.dyn_o rts/dist-install/build/Messages.dyn_o rts/dist-install/build/OldARMAtomic.dyn_o rts/dist-install/build/PathUtils.dyn_o rts/dist-install/build/Pool.dyn_o rts/dist-install/build/Printer.dyn_o rts/dist-install/build/ProfHeap.dyn_o rts/dist-install/build/ProfilerReport.dyn_o rts/dist-install/build/ProfilerReportJson.dyn_o rts/dist-install/build/Profiling.dyn_o rts/dist-install/build/Proftimer.dyn_o rts/dist-install/build/RaiseAsync.dyn_o rts/dist-install/build/ReportMemoryMap.dyn_o rts/dist-install/build/RetainerProfile.dyn_o rts/dist-install/build/RetainerSet.dyn_o rts/dist-install/build/RtsAPI.dyn_o rts/dist-install/build/RtsDllMain.dyn_o rts/dist-install/build/RtsFlags.dyn_o rts/dist-install/build/RtsMain.dyn_o rts/dist-install/build/RtsMessages.dyn_o rts/dist-install/build/RtsStartup.dyn_o rts/dist-install/build/RtsSymbolInfo.dyn_o rts/dist-install/build/RtsSymbols.dyn_o rts/dist-install/build/RtsUtils.dyn_o rts/dist-install/build/STM.dyn_o rts/dist-install/build/Schedule.dyn_o rts/dist-install/build/Sparks.dyn_o rts/dist-install/build/SpinLock.dyn_o rts/dist-install/build/StableName.dyn_o rts/dist-install/build/StablePtr.dyn_o rts/dist-install/build/StaticPtrTable.dyn_o rts/dist-install/build/Stats.dyn_o rts/dist-install/build/StgCRun.dyn_o rts/dist-install/build/StgPrimFloat.dyn_o rts/dist-install/build/Task.dyn_o rts/dist-install/build/ThreadLabels.dyn_o rts/dist-install/build/ThreadPaused.dyn_o rts/dist-install/build/Threads.dyn_o rts/dist-install/build/Ticky.dyn_o rts/dist-install/build/Timer.dyn_o rts/dist-install/build/TopHandler.dyn_o rts/dist-install/build/Trace.dyn_o rts/dist-install/build/TraverseHeap.dyn_o rts/dist-install/build/TraverseHeapTest.dyn_o rts/dist-install/build/WSDeque.dyn_o rts/dist-install/build/Weak.dyn_o rts/dist-install/build/fs.dyn_o rts/dist-install/build/hooks/FlagDefaults.dyn_o rts/dist-install/build/hooks/LongGCSync.dyn_o rts/dist-install/build/hooks/MallocFail.dyn_o rts/dist-install/build/hooks/OnExit.dyn_o rts/dist-install/build/hooks/OutOfHeap.dyn_o rts/dist-install/build/hooks/StackOverflow.dyn_o rts/dist-install/build/sm/BlockAlloc.dyn_o rts/dist-install/build/sm/CNF.dyn_o rts/dist-install/build/sm/Compact.dyn_o rts/dist-install/build/sm/Evac.dyn_o rts/dist-install/build/sm/Evac_thr.dyn_o rts/dist-install/build/sm/GC.dyn_o rts/dist-install/build/sm/GCAux.dyn_o rts/dist-install/build/sm/GCUtils.dyn_o rts/dist-install/build/sm/MBlock.dyn_o rts/dist-install/build/sm/MarkWeak.dyn_o rts/dist-install/build/sm/NonMoving.dyn_o rts/dist-install/build/sm/NonMovingCensus.dyn_o rts/dist-install/build/sm/NonMovingMark.dyn_o rts/dist-install/build/sm/NonMovingScav.dyn_o rts/dist-install/build/sm/NonMovingShortcut.dyn_o rts/dist-install/build/sm/NonMovingSweep.dyn_o rts/dist-install/build/sm/Sanity.dyn_o rts/dist-install/build/sm/Scav.dyn_o rts/dist-install/build/sm/Scav_thr.dyn_o rts/dist-install/build/sm/Storage.dyn_o rts/dist-install/build/sm/Sweep.dyn_o rts/dist-install/build/eventlog/EventLog.dyn_o rts/dist-install/build/eventlog/EventLogWriter.dyn_o rts/dist-install/build/linker/CacheFlush.dyn_o rts/dist-install/build/linker/Elf.dyn_o rts/dist-install/build/linker/LoadArchive.dyn_o rts/dist-install/build/linker/M32Alloc.dyn_o rts/dist-install/build/linker/MMap.dyn_o rts/dist-install/build/linker/MachO.dyn_o rts/dist-install/build/linker/PEi386.dyn_o rts/dist-install/build/linker/SymbolExtras.dyn_o rts/dist-install/build/linker/elf_got.dyn_o rts/dist-install/build/linker/elf_plt.dyn_o rts/dist-install/build/linker/elf_plt_aarch64.dyn_o rts/dist-install/build/linker/elf_plt_arm.dyn_o rts/dist-install/build/linker/elf_reloc.dyn_o rts/dist-install/build/linker/elf_reloc_aarch64.dyn_o rts/dist-install/build/linker/elf_tlsgd.dyn_o rts/dist-install/build/linker/elf_util.dyn_o rts/dist-install/build/linker/macho/plt.dyn_o rts/dist-install/build/linker/macho/plt_aarch64.dyn_o rts/dist-install/build/posix/GetEnv.dyn_o rts/dist-install/build/posix/GetTime.dyn_o rts/dist-install/build/posix/OSMem.dyn_o rts/dist-install/build/posix/OSThreads.dyn_o rts/dist-install/build/posix/Select.dyn_o rts/dist-install/build/posix/Signals.dyn_o rts/dist-install/build/posix/TTY.dyn_o rts/dist-install/build/posix/Ticker.dyn_o rts/dist-install/build/adjustor/AdjustorPool.dyn_o rts/dist-install/build/adjustor/NativeAmd64.dyn_o rts/dist-install/build/StgCRunAsm.dyn_o rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o rts/dist-install/build/Apply.dyn_o rts/dist-install/build/Compact.dyn_o rts/dist-install/build/Exception.dyn_o rts/dist-install/build/HeapStackCheck.dyn_o rts/dist-install/build/PrimOps.dyn_o rts/dist-install/build/StgMiscClosures.dyn_o rts/dist-install/build/StgStartup.dyn_o rts/dist-install/build/StgStdThunks.dyn_o rts/dist-install/build/Updates.dyn_o rts/dist-install/build/AutoApply.dyn_o -optl-Wl,-z -optl-Wl,wxneeded -fPIC -dynamic -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist-install/build -Irts/dist-install/build -irts/dist-install/build/./autogen -Irts/dist-install/build/./autogen -Irts/include/../dist-install/build/include -Irts/include/. -Irts/. -optP-DCOMPILING_RTS -optP-DFS_NAMESPACE=rts -O2 -Wcpp-undef -Wnoncanonical-monad-instances -fno-use-rpaths -optl-Wl,-zorigin -o rts/dist-install/build/libHSrts-ghc9.3.20220301.so
ld.lld: error: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o
>>> referenced by NativeAmd64Asm.S
>>> rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o:(.text+0x50)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
`cc' failed in phase `Linker'. (Exit code: 1)
gmake[1]: *** [rts/ghc.mk:353: rts/dist-install/build/libHSrts-ghc9.3.20220301.so] Error 1
gmake: *** [Makefile:128: all] Error 2
```
The file indeed has an R_X86_64_64 relocation:
```
% "inplace/bin/ghc-stage1" -optc--target=x86_64-unknown-openbsd -optc-Wall -optc-Werror -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-Wno-unused-label -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist-install/build/./autogen -optc-Irts/include/../dist-install/build/include -optc-Irts/include/. -optc-Irts/. -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-Wno-unknown-pragmas -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DDYNAMIC -optc-DRtsWay=\"rts_dyn\" -fPIC -dynamic -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist-install/build -Irts/dist-install/build -irts/dist-install/build/./autogen -Irts/dist-install/build/./autogen -Irts/include/../dist-install/build/include -Irts/include/. -Irts/. -optP-DCOMPILING_RTS -optP-DFS_NAMESPACE=rts -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/adjustor/NativeAmd64Asm.S -o rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o
% file rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o
rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o: ELF 64-bit LSB relocatable, x86-64, version 1
% objdump -r rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o
rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o: file format elf64-x86-64
RELOCATION RECORDS FOR [.text]:
OFFSET TYPE VALUE
0000000000000050 R_X86_64_64 .text+0x0000000000000060
```
Doing a naive monkey-see-monkey-do doesn't help:
```
% git diff rts/adjustor/NativeAmd64Asm.S
diff --git a/rts/adjustor/NativeAmd64Asm.S b/rts/adjustor/NativeAmd64Asm.S
index 32e8da50fd..7c4444d46e 100644
--- a/rts/adjustor/NativeAmd64Asm.S
+++ b/rts/adjustor/NativeAmd64Asm.S
@@ -14,7 +14,7 @@
CSYM(x):
-#if defined(darwin_HOST_OS)
+#if defined(darwin_HOST_OS) || defined(openbsd_HOST_OS)
/*
* Note [Adjustor templates live in data section on Darwin]
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -84,7 +84,7 @@ lcl_complex_ccall_adjustor_context: // See Note [Adjustors: Local symbol referen
DECLARE_CSYM(complex_ccall_adjustor_end)
-#if defined(darwin_HOST_OS)
+#if defined(darwin_HOST_OS) || defined(openbsd_HOST_OS)
/* See Note [Adjustor templates live in data section on Darwin]. */
.section __TEXT,__text
#endif
% "inplace/bin/ghc-stage1" -optc--target=x86_64-unknown-openbsd -optc-Wall -optc-Werror -optc-Wall -optc-Wextra -optc-Wstrict-prototypes -optc-Wmissing-prototypes -optc-Wmissing-declarations -optc-Winline -optc-Wpointer-arith -optc-Wmissing-noreturn -optc-Wnested-externs -optc-Wredundant-decls -optc-Wno-aggregate-return -optc-Wno-unused-label -optc-fno-strict-aliasing -optc-fno-common -optc-Irts/dist-install/build/./autogen -optc-Irts/include/../dist-install/build/include -optc-Irts/include/. -optc-Irts/. -optc-DCOMPILING_RTS -optc-DFS_NAMESPACE=rts -optc-Wno-unknown-pragmas -optc-O2 -optc-fomit-frame-pointer -optc-g -optc-DDYNAMIC -optc-DRtsWay=\"rts_dyn\" -fPIC -dynamic -O0 -H64m -Wall -fllvm-fill-undef-with-garbage -Werror -this-unit-id rts -dcmm-lint -package-env - -i -irts -irts/dist-install/build -Irts/dist-install/build -irts/dist-install/build/./autogen -Irts/dist-install/build/./autogen -Irts/include/../dist-install/build/include -Irts/include/. -Irts/. -optP-DCOMPILING_RTS -optP-DFS_NAMESPACE=rts -O2 -Wcpp-undef -Wnoncanonical-monad-instances -c rts/adjustor/NativeAmd64Asm.S -o rts/dist-install/build/adjustor/NativeAmd64Asm.dyn_o
rts/adjustor/NativeAmd64Asm.S:29:17: error:
error: expected string in directive
|
29 | .section __DATA,__data
| ^
.section __DATA,__data
^
rts/adjustor/NativeAmd64Asm.S:89:17: error:
error: expected string in directive
|
89 | .section __TEXT,__text
| ^
.section __TEXT,__text
^
`cc' failed in phase `Assembler'. (Exit code: 1)
%
```9.4.1https://gitlab.haskell.org/ghc/ghc/-/issues/21149servant-0.19 fails to compile on HEAD due to TypeErrors triggering more eagerly2022-08-24T17:52:16ZRyan Scottservant-0.19 fails to compile on HEAD due to TypeErrors triggering more eagerly`servant-0.19` fails to build on GHC HEAD. Here is a minimized version of the issue:
```hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE PolyKi...`servant-0.19` fails to build on GHC HEAD. Here is a minimized version of the issue:
```hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE Haskell2010 #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module Bug where
import Data.Kind
import GHC.TypeLits
-- | No instance exists for @tycls (expr :> ...)@ because
-- @expr@ is not recognised.
type NoInstanceForSub (tycls :: k) (expr :: k') =
Text "There is no instance for " :<>: ShowType tycls
:<>: Text " (" :<>: ShowType expr :<>: Text " :> ...)"
-- | No instance exists for @expr@.
type NoInstanceFor (expr :: k) =
Text "There is no instance for " :<>: ShowType expr
-- | No instance exists for @tycls (expr :> ...)@ because @expr@ is not fully saturated.
type PartialApplication (tycls :: k) (expr :: k') =
NoInstanceForSub tycls expr
:$$: ShowType expr :<>: Text " expects " :<>: ShowType (Arity expr) :<>: Text " more arguments"
-- The arity of a combinator, i.e. the number of required arguments.
type Arity (ty :: k) = Arity' k
type Arity' :: k -> Nat
type family Arity' (ty :: k) :: Nat where
Arity' (_ -> ty) = 1 + Arity' ty
Arity' _ = 0
data (path :: k) :> (a :: *)
class HasLink endpoint where
instance TypeError (PartialApplication HasLink arr) => HasLink ((arr :: a -> b) :> sub)
```
This compiles with GHC 9.0.2 and 9.2.1, but fails to compile with HEAD:
```
$ ~/Software/ghc-9.3.20220216/bin/ghc Bug.hs
[1 of 1] Compiling Bug ( Bug.hs, Bug.o )
Bug.hs:40:10: error:
• There is no instance for HasLink (arr :> ...)
arr expects 1 + Arity' b more arguments
• In the ambiguity check for an instance declaration
In the instance declaration for ‘HasLink ((arr :: a -> b) :> sub)’
|
40 | instance TypeError (PartialApplication HasLink arr) => HasLink ((arr :: a -> b) :> sub)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
I'm unclear if this change is intended behavior or not, but since I couldn't find any mention of `TypeError`'s behavior changing in the [9.4 release notes](https://gitlab.haskell.org/ghc/ghc/-/blob/d734ef8f78203b856dcfaf19eaebfed6ec623850/docs/users_guide/9.4.1-notes.rst), I decided to open an issue.9.4.1sheafsam.derbyshire@gmail.comsheafsam.derbyshire@gmail.comhttps://gitlab.haskell.org/ghc/ghc/-/issues/21141Nondeterministic segfault on simple hspec program with GHC 9.0 only2022-07-12T13:55:43ZRyan ScottNondeterministic segfault on simple hspec program with GHC 9.0 only_(Originally reported at https://github.com/ekmett/reflection/issues/51.)_
The [`reflection-2.1.6`](https://hackage.haskell.org/package/reflection-2.1.6) test suite nondeterministically segfaults on Linux and macOS when compiled with GH..._(Originally reported at https://github.com/ekmett/reflection/issues/51.)_
The [`reflection-2.1.6`](https://hackage.haskell.org/package/reflection-2.1.6) test suite nondeterministically segfaults on Linux and macOS when compiled with GHC 9.0.1 or 9.0.2. The furthest I've managed to minimize the issue is:
```hs
{-# LANGUAGE PackageImports #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Main (main) where
import Control.Exception (ArithException(..), evaluate)
import Numeric.Natural (Natural)
import "hspec" Test.Hspec
import "hspec" Test.Hspec.QuickCheck
import "QuickCheck" Test.QuickCheck (Negative(..), NonNegative(..))
main :: IO ()
main = hspec spec
spec :: Spec
spec =
describe "A" $ do
describe "B" $ do
prop "identity" $
\(NonNegative (i :: Integer)) -> i `shouldBe` i
prop "should throw an Underflow exception on negative inputs" $
\(Negative (i :: Integer)) ->
evaluate (fromInteger i :: Natural) `shouldThrow` (== Underflow)
```
With GHC 8.10.7 or 9.2.1, this works as expected:
```
$ ghc-8.10.7 Bug.hs && ./Bug
Loaded package environment from /home/ryanglscott/Documents/Hacking/Haskell/ci-maintenance/checkout/ekmett/reflection/.ghc.environment.x86_64-linux-8.10.7
[1 of 1] Compiling Main ( Bug.hs, Bug.o )
Linking Bug ...
A
B
identity [✔]
+++ OK, passed 100 tests.
should throw an Underflow exception on negative inputs [✔]
+++ OK, passed 100 tests.
Finished in 0.0009 seconds
2 examples, 0 failures
$ ghc-9.2.1 Bug.hs && ./Bug
Loaded package environment from /home/ryanglscott/Documents/Hacking/Haskell/ci-maintenance/checkout/ekmett/reflection/.ghc.environment.x86_64-linux-9.2.1
[1 of 1] Compiling Main ( Bug.hs, Bug.o )
Linking Bug ...
A
B
identity [✔]
+++ OK, passed 100 tests.
should throw an Underflow exception on negative inputs [✔]
+++ OK, passed 100 tests.
Finished in 0.0013 seconds
2 examples, 0 failures
```
With GHC 9.0.2, however, this can segfault:
```
$ ghc-9.0.2 Bug.hs && ./Bug
Loaded package environment from /home/ryanglscott/Documents/Hacking/Haskell/ci-maintenance/checkout/ekmett/reflection/.ghc.environment.x86_64-linux-9.0.2
[1 of 1] Compiling Main ( Bug.hs, Bug.o )
Linking Bug ...
A
B
identity [✔]
+++ OK, passed 100 tests.
should throw an Underflow exception on negative inputs [ ]Segmentation fault (core dumped)
```
This is somewhat nondeterministic. In situations where it doesn't segfault, an incorrect runtime result will be observed:
```
$ ./Bug
A
B
identity [✔]
+++ OK, passed 100 tests.
should throw an Underflow exception on negative inputs [✘]
Failures:
Bug.hs:22:47:
1) A.B should throw an Underflow exception on negative inputs
Falsifiable (after 54 tests and 2 shrinks):
Negative {getNegative = -1}
did not get expected exception: ArithException
To rerun use: --match "/A/B/should throw an Underflow exception on negative inputs/"
Randomized with seed 1065015581
Finished in 0.0028 seconds
2 examples, 1 failure
```
This example proves remarkably resistant to minimization, as attempting to delete code in various places seemingly makes the bug disappear.9.0.3Ben GamariBen Gamari