ghc-9.15.20250912: something to do with specialization causes SIGSEGV when the program is run
Edit2: please see the small reproducer by @sheaf and @MangoIV.
Edit: The old plugins used in this repro don't work with newest HEAD. I've ported the repro to ghc-9.15.20251115 and to the new versions of plugins as released on Hackage. This is on branch VTA-fail-modern. Note that the test will likely not pass once the bug is fixed, unlike in the original repro, but as long as it doesn't segfault any more, we won.
Summary
This may be related to #23109, since the code snapshot is from a similar date, so I've added it to the list in that ticket. I haven't tried most of the other repros from the list yet with current HEAD, but current master of horde-ad compiles and runs fine at least (which also means this is not blocking me personally in any way).
This test crashes at runtime. Running under gdb shows it's a SIGSEGV:
gdb dist-newstyle/build/x86_64-linux/ghc-9.15.20250912/horde-ad-0.1.0.0/t/simplifiedOnlyTest/build/simplifiedOnlyTest/simplifiedOnlyTest
...
Thread 5 "ghc_worker" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffe7fff6c0 (LWP 442542)]
0x0000000001bb6ff8 in stg_ap_0_fast ()
(gdb) bt
#0 0x0000000001bb6ff8 in stg_ap_0_fast ()
#1 0x0000000000000000 in ?? ()
Removing --ghc-options="-fpolymorphic-specialisation" from the repro makes the test pass.
It's possible the cause is unsafe operations in my code that happen to show their unsoundness only when more specialization happens, but I think it's not very likely.
I've minimized the code minimally so far, but I'm ready to assist in any way. Linting (-dcore-lint -dstg-lint -dcmm-lint -dtag-inference-checks) doesn't error out.
Steps to reproduce
git clone git@github.com:Mikolaj/horde-ad.git
cd horde-ad
git checkout VTA-fail-fast
rm -f cabal.project.local
rm -rf ~/.cabal/packages/head.hackage.ghc.haskell.org
cabal update
cabal test -w /home/mikolaj/r/ghc.13092025/ghc/_build/stage1/bin/ghc --allow-newer --enable-optimization --ghc-options="-fpolymorphic-specialisation"
Expected behavior
Test passes with --ghc-options="-fpolymorphic-specialisation".
Environment
- GHC version used: ghc-9.15.20250912
Optional:
- Operating System: Ubuntu
- System Architecture: AMD64