While trying to debug why my test didn't seem to be running, I got an internal error (below).
After a clean and rebuild it happened again so it's not a flake. Unfortunately I don't know what's causing it so I can't produce an MWE, but I can link to the project and commit on GitHub:
Progress 9/10: persistwrap-0.1.0.0test/Driver.hs test_widget_schemas: persistwrap-test: internal error: PAP object entered! (GHC version 8.4.4 for x86_64_apple_darwin) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabugpersistwrap-test: SignalException 6persistwrap-0.1.0.0: Test suite persistwrap-test failedCompleted 10 action(s).Test suite failure for package persistwrap-0.1.0.0 persistwrap-test: exited with: ExitFailure (-6)Logs printed to console
Trac metadata
Trac field
Value
Version
8.4.4
Type
Bug
TypeOfFailure
OtherFailure
Priority
normal
Resolution
Unresolved
Component
Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
I can confirm that this code also panics on 8.6.3 (after lots of tweaking to make it compile). Alas, this repo is absolutely massive, and I haven't the slightest clue where to begin minimizing it. Any help you could provide would be massively helpful.
One thing to note is that the insertX function appears to be important here. The program still crashes if you make the following change to test/PersistWrap/WidgetSpec.hs:
stack test persistwrap:persistwrap-test --ta '-p "Widget.should get back"'
I get
Progress 1/2: persistwrap-0.1.0.0test/Driver.hs widget Widget should get back what you put in: STM returning ValueSnd (V (PV 3))persistwrap-test: internal error: PAP object entered! (GHC version 8.4.4 for x86_64_apple_darwin) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
So the message outside the return is getting printed but not the one on the inside.
Progress 9/10: persistwrap-0.1.0.0test/Driver.hs widget Widget should get back what you put in: Before: <foreign key: abc>STM returning <foreign key: abc>persistwrap-test: internal error: PAP object entered! (GHC version 8.4.4 for x86_64_apple_darwin) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
Right, but a Core Lint failure would tell us at compile-time whether and where the compiler misstepped. Sadly it looks like this won't be so simple to find.
dnspies, any help you could provide in minimizing the reproducer would be greatly appreciated.
@RyanGlScott can you share your tweaks for GHC 8.6? I'm using stack2cabal to build this using cabal as I don't have stack and am hitting the 8.6 compile errors now.
We're running into a similar problem at my day job (DFINITY) which is hurting our ability to profile and optimise, but our reproduction only occurs after running a network program for 10+ minutes. This one seems maybe easier to minimise.
$ cabal new-test --enable-tests persistwrap:persistwrap-testBuild profile: -w ghc-8.6.4 -O1In order, the following will be built (use -v for more details): - persistwrap-0.1.0.0 (test:persistwrap-test) (first run)Preprocessing test suite 'persistwrap-test' for persistwrap-0.1.0.0..Building test suite 'persistwrap-test' for persistwrap-0.1.0.0..Running 1 test suites...Test suite persistwrap-test: RUNNING...test/Driver.hs widget Widget should get back what you put in: persistwrap-test: internal error: PAP object entered! (GHC version 8.6.4 for x86_64_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabugTest suite persistwrap-test: FAILTest suite logged to:/home/rgscott/Documents/Hacking/Haskell/persistwrap/dist-newstyle/build/x86_64-linux/ghc-8.6.4/persistwrap-0.1.0.0/t/persistwrap-test/test/persistwrap-0.1.0.0-persistwrap-test.log0 of 1 test suites (0 of 1 test cases) passed.cabal: Tests failed for test:persistwrap-test from persistwrap-0.1.0.0.
Thanks! Here's a smaller reproduction, outside of the testing framework but still using some persistwrap functions. You can run it directly with ghc Test.hs && ./Test as long as persistwrap is installed.
I tried to make it even smaller but got into a thicket trying to inline functions like unsafeSetupEmptyTables etc, perhaps @trac-dnspies can help or take over from here.
16066.hs
{-# LANGUAGE DataKinds #-}{-# LANGUAGE TypeApplications #-}{-# OPTIONS_GHC -O -Wunused-imports -dcmm-lint -dstg-lint -dcore-lint #-}moduleMain(main)whereimportControl.Monad(join)importData.Singletons.Prelude(withSomeSing)importPersistWrap.Itemized(Itemized(runItemized))importPersistWrap.Persistable(entitySchemas)importPersistWrap.Persisted(insertX)importPersistWrap.Structure(StructureOf)importPersistWrap.Table.BackEnd.STM.Internal(unsafeSetupEmptyTables)importPersistWrap.Table.Transaction(MonadPersist(atomicTransaction))main::IO()main=doletschema=entitySchemas@"a"@(StructureOfInt)letaction=withSomeSingschema$\sschema->unsafeSetupEmptyTablessschema(const(runItemizedwidgetAssertions))joinaction>>=print--HIDESBUG:--widgetAssertions :: Itemized Tbl (STMPersist s IO) (IO ())widgetAssertions::(MonadPersistm)=>ItemizedTblm(IO())widgetAssertions=atomicTransaction$do_<-insertX@"a"1_<-insertX@"a"1--HIDESBUG:--pure (pure ())error"exit assertion"typeTbl='['("a",Int)]
Hah, that's about the same point where I gave up on minimizing this :) That code is deceivingly small in appearance—there's a lot happening underneath the hood!
If someone familiar with this codebase could help minimize this further, that would be greatly appreciated, as I lack the expertise to do so.
Two things that would make this easier (a) some automatic inliner tool, similar to the output of gcc -E (b) being able to find out which instances are being used and where it's being imported from. Any clues on those fronts would also be appreciated.
Progress update, here's a smaller example plus a patch needed to make it work (it exposes some internal constructors).
I am actually not sure how to minimise it more, please have a look and see if you have any ideas. atomicTransaction seems to be a good next step, however if I inline the typeclass constraint away with the actual type (IO) the bug goes away! :(
Pretty much everything else that remains, e.g. runItemized, is trivial wrappers etc, and can't be minimised before we deal with atomicTransaction...
16066.hs
{-# LANGUAGE DataKinds #-}{-# LANGUAGE GADTs #-}{-# LANGUAGE PartialTypeSignatures #-}{-# LANGUAGE PolyKinds #-}{-# LANGUAGE RankNTypes #-}{-# LANGUAGE ScopedTypeVariables #-}{-# LANGUAGE TypeApplications #-}{-# LANGUAGE TypeFamilies #-}{-# LANGUAGE TypeOperators #-}{-# OPTIONS_GHC -O -Wunused-imports -dcmm-lint -dstg-lint -dcore-lint #-}moduleMain(main)whereimportControl.Monad(join)importControl.Concurrent.STM.TVar(newTVarIO)importControl.Monad.Reader(runReaderT)importqualifiedData.MapasMap(singleton)importConsin(Some(Some))importConsin.SingMap(SingMap(SingMap))importData.Singletons.Prelude(SingI(sing),SomeSing(SomeSing),withSingI)-- for type SchimportqualifiedPersistWrap.Table.Schema.InternalasSInternal(Schema(Schema),Column(Column),BaseColumn(Prim))importPersistWrap.Primitives(PrimName(PrimInt64))-- for mschemaimportPersistWrap.Table.Schema(Sing(SSchema))importPersistWrap.Table.Reflect(SomeTableNamed(SomeTableNamed))importqualifiedPersistWrap.Table.BackEnd.STM.InternalasInternal(Table(Table))-- for widgetAssertionsimportPersistWrap.Itemized(Itemized(runItemized))importPersistWrap.Persisted(insertX)importPersistWrap.Table.BackEnd.STM.Internal(STMPersist(unSTMPersist))importPersistWrap.Table.Transaction(MonadPersist(atomicTransaction))exec::IO(IO())exec=doletsch=sing@Sch(k,v)<-caseschofSSchemanamecols->dov<-Internal.Table@_@Sch<$>newTVarIO[]pure(SomeSingname,withSingIname$Some$SomeTableNamedcolsv)letmschema=Map.singletonkvletaction=unSTMPersist$runItemizedwidgetAssertions--let schs = SCons sch SNilrunReaderT(withSingI(error"schs never accessed")action)(SingMapmschema)main::IO()main=joinexec>>=print--HIDESBUG:--widgetAssertions :: Itemized Tbl (STMPersist s IO) (IO ())widgetAssertions::(MonadPersistm)=>ItemizedTblm(IO())widgetAssertions=atomicTransaction$do_<-insertX@"a"1_<-insertX@"a"1--HIDESBUG:--pure (pure ())error"exit never happens"typeTbl='['("a",Int)]typeSch='SInternal.Schema"a"'['("value",'SInternal.Column'False('SInternal.Prim'PrimInt64))]
Unfortunately the reproducer is still huge. It'd be best if we could find a smaller reproducer (with less dependencies) but perhaps it might also help to build this program with -debug and run with +RTS -DS. If you also make the nurseries small (e.g. +RTS -A10k) you end up doing a lot of sanity checking, which may help with diagnosing the problem.