haskell.nix
haskell.nix copied to clipboard
GHC plugins (specifically record-dot-preprocessor's Plugin) fail with segfault
This template is a guide only, feel free add or omit sections as appropriate.
Using compiler plugin (record-dot-preprocessor) lead GHC to crash (which not happens with regular GHC outside haskell.nix)
A clear and concise description of what the bug is, including:
- Build system (
x86_64-linux
). - GHC version. 8.10.7
- Haskell.nix version (or commit) used -- b92bb7eea51d8740bcbd3c720f3609407d79e5d7
Steps To Reproduce
I'd make repo branch -- https://github.com/avnik/record-dot-preprocessor/tree/haskell.nix-segfault-repro (current master of RDP with flake.nix from getting started example with minimal editing of cabal name inside)
nix develop
then cabal test
A clear and concise description of what you expected to happen.
[4 of 6] Compiling PluginExample ( test/PluginExample.hs, /home/avn/work/juspay/record-dot-preprocessor/dist-newstyle/build/x86_64-linux/ghc-8.10.7/record-dot-preprocessor-0.2.15/t/record-dot-preprocessor-test/build/record-dot-preprocessor-test/record-dot-preprocessor-test-tmp/PluginExample.o )
Error: cabal: Failed to build test:record-dot-preprocessor-test from
record-dot-preprocessor-0.2.15. The build process segfaulted (i.e. SIGSEGV)
Expected behavior, that it's build. (we use RDP on both 8.10.7 and 8.8.4 with regular nixpkgs haskell framework)
PS I'd check more ghc versions and try to make "do-nothing" plugin, to check, if plugins works at all. PPS Looks like a generic problem for 8.10.7, empty demo plugin trigger same problem https://github.com/avnik/haskell-nix-plugin-segfault-repro
@MangoIV has also run into this
I do a more clean repro, with do-nothing plugin https://github.com/avnik/haskell-nix-plugin-segfault-repro
-- | GHC plugin.
plugin :: GHC.Plugin
plugin = GHC.defaultPlugin
{ GHC.pluginRecompile = GHC.purePlugin -- Adding THIS line triggering segfault
}
Tested different versions, that a 8.10.* specific problem, try to check 8106 or earlier
Happens with 8.10.4-8.10.7, earlier 8.10 just don't builds
@MangoIV has also run into this
just wanted to add that I did not actually fix the issue, I just removed the plugin for the time being because it was a quick refactor. It's unfortunate nonetheless.
Well, in worst case I can neglect 8.10.*, because we have 8.8.4 "mainline", and use 8.10 for tooling (and can switch to 9.0/9.2 in last case).
But could we add "plugin test" for haskell.nix testsuite, to don't allow other revisions break?
@MangoIV has also run into this
just wanted to add that I did not actually fix the issue, I just removed the plugin for the time being because it was a quick refactor. It's unfortunate nonetheless.
Also wanted to add that I had the same issue, and I did not actually fix the issue either. I removed the plugin as well.
GDB reports:
Loading package ghc-prim-0.6.1 ... linking ... done.
Loading package integer-gmp-1.0.3.0 ... linking ... done.
Loading package base-4.14.3.0 ... linking ... done.
Loading package record-hasfield-1.0 ... linking ... done.
Loading package clock-0.8.3 ... linking ... done.
Loading package filepath-1.4.2.1 ... linking ... done.
Loading package array-0.5.4.0 ... linking ... done.
Loading package deepseq-1.4.4.0 ... linking ... done.
Loading package time-1.9.3 ... linking ... done.
Loading package bytestring-0.10.12.0 ... linking ... done.
Loading package unix-2.7.2.2 ... linking ... done.
Loading package directory-1.3.6.0 ... linking ... done.
Loading package process-1.6.13.2 ... linking ... done.
Loading package extra-1.7.12 ... linking ... done.
Loading package containers-0.6.5.1 ... linking ... done.
Loading package binary-0.8.8.0 ... linking ... done.
Loading package ghc-boot-th-8.10.7 ... linking ... done.
Loading package ghc-boot-8.10.7 ... linking ... done.
Loading package ghc-heap-8.10.7 ... linking ... done.
Loading package pretty-1.1.3.6 ... linking ... done.
Loading package template-haskell-2.16.0.0 ... linking ... done.
Loading package transformers-0.5.6.2 ... linking ... done.
Loading package ghci-8.10.7 ... linking ... done.
Loading package hpc-0.6.1.0 ... linking ... done.
Loading package terminfo-0.4.1.4 ... linking ... done.
Loading package ghc-8.10.7 ... linking ... done.
Loading package base-orphans-0.8.7 ... linking ... done.
Loading package text-1.2.4.1 ... linking ... done.
Loading package hashable-1.4.1.0 ... linking ... done.
Loading package syb-0.7.2.2 ... linking ... done.
Loading package unordered-containers-0.2.19.1 ... linking ... done.
Loading package uniplate-1.6.13 ... linking ... done.
Loading package record-dot-preprocessor-0.2.15 ... linking ... done.
Search directories (user):
Search directories (gcc):
Coercing a value in getValueSafely...
Successfully evaluated coercion
*** Checking old interface for PluginExample (use -ddump-hi-diffs for more details):
[4 of 6] Compiling PluginExample ( test/PluginExample.hs, /home/hsyl20/projects/ghc-failure/record-dot-preprocessor/dist-newstyle/build/x86_64-linux/ghc-8.10.7/record-dot-preprocessor-0.2.15/t/record-dot-preprocessor-test/build/record-dot-preprocessor-test/record-dot-preprocessor-test-tmp/PluginExample.o )
*** Parser [PluginExample]:
!!! Parser [PluginExample]: finished in 3.72 milliseconds, allocated 12.126 megabytes
*** Renamer/typechecker [PluginExample]:
!!! Renamer/typechecker [PluginExample]: finished in 56.51 milliseconds, allocated 77.267 megabytes
*** Desugar [PluginExample]:
Result size of Desugar (before optimization)
= {terms: 4,533, types: 6,714, coercions: 336, joins: 0/234}
Result size of Desugar (after optimization)
= {terms: 3,479, types: 5,080, coercions: 433, joins: 1/15}
!!! Desugar [PluginExample]: finished in 15.52 milliseconds, allocated 28.174 megabytes
Thread 1 "ghc" received signal SIGSEGV, Segmentation fault.
0x00007ffff63a0155 in ghc_CoreMonad_plusSimplCount_info () from /nix/store/x2kp6b7xwngvfzrh6pip3did10i08la4-ghc-8.10.7/lib/ghc-8.10.7/bin/../ghc-8.10.7/libHSghc-8.10.7-ghc8.10.7.so
(gdb) bt
#0 0x00007ffff63a0155 in ghc_CoreMonad_plusSimplCount_info () from /nix/store/x2kp6b7xwngvfzrh6pip3did10i08la4-ghc-8.10.7/lib/ghc-8.10.7/bin/../ghc-8.10.7/libHSghc-8.10.7-ghc8.10.7.so
#1 0x0000000000000000 in ?? ()
It crashes on the following instruction: mov 0x7(%rbx),%rbx
Indeed the contents of %rbx is: 0xad8000007ffff639
which isn't a valid address.
I could be meant to be 0x7ffff639ad80
which would be a a valid address, the address of ghc_CoreMonad_zdfHasDynFlagsCoreM1_info
, which symbol is defined as:
000000000359ad80 g F .text 000000000000006c ghc_CoreMonad_zdfHasDynFlagsCoreM1_info
I still don't know how we end up with a wrong address.
GHC patches gone wrong? We should spend time removing them anyway.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This should be reopened tbh