Opened 8 weeks ago

Last modified 10 days ago

#16087 new bug

TH tests fail in ext-interp way when ghc-stage2 is built using LLVM

Reported by: bgamari Owned by:
Priority: normal Milestone: 8.10.1
Component: Compiler (LLVM) Version: 8.6.3
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

This is a continuation of #15274.

Currently the testsuite fails with around 40 test failures, all in th/ in the ext-interp way when building GHC with BUILD_FLAVOUR=perf-llvm:

Unexpected results from:
TEST="ClosedFam1TH T10620 T10828 T11721_TH T11797 T12478_1 T12646 T13642 T14060 T15502 T15738 T15792 T15845 T1835 T3920 T4135 T4188 T5037 T5362 T7477 T8761 T8884 T8953 T9262 T9692 T9738 TH_RichKinds TH_RichKinds2 TH_Roles3 TH_TyInstWhere2 TH_implicitParams TH_reifyDecl1 TH_reifyExplicitForAllFams TH_reifyInstances TH_reifyMkName TH_repE2 TH_repGuard TH_repPrim TH_repPrim2 TH_repUnboxedTuples"

SUMMARY for test run started at Sun Dec 23 06:01:39 2018 UTC
 0:10:09 spent to go through
    6745 total tests, which gave rise to
   26266 test cases, of which
   19055 were skipped

      42 had missing libraries
    7040 expected passes
      89 expected failures

       0 caused framework failures
       0 caused framework warnings
       0 unexpected passes
      40 unexpected failures
       0 unexpected stat failures

Unexpected failures:
   th/TH_repE2.run                    TH_repE2 [exit code non-0] (ext-interp)
   th/TH_repPrim.run                  TH_repPrim [exit code non-0] (ext-interp)
   th/TH_repPrim2.run                 TH_repPrim2 [exit code non-0] (ext-interp)
   th/TH_repUnboxedTuples.run         TH_repUnboxedTuples [exit code non-0] (ext-interp)
   th/TH_repGuard.run                 TH_repGuard [exit code non-0] (ext-interp)
   th/TH_reifyDecl1.run               TH_reifyDecl1 [exit code non-0] (ext-interp)
   th/TH_reifyMkName.run              TH_reifyMkName [exit code non-0] (ext-interp)
   th/TH_reifyInstances.run           TH_reifyInstances [exit code non-0] (ext-interp)
   th/TH_reifyExplicitForAllFams.run  TH_reifyExplicitForAllFams [exit code non-0] (ext-interp)
   th/T3920.run                       T3920 [exit code non-0] (ext-interp)
   th/T4188.run                       T4188 [exit code non-0] (ext-interp)
   th/T1835.run                       T1835 [exit code non-0] (ext-interp)
   th/T5037.run                       T5037 [exit code non-0] (ext-interp)
   th/T5362.run                       T5362 [exit code non-0] (ext-interp)
   th/TH_RichKinds.run                TH_RichKinds [exit code non-0] (ext-interp)
   th/TH_RichKinds2.run               TH_RichKinds2 [exit code non-0] (ext-interp)
   th/T4135.run                       T4135 [exit code non-0] (ext-interp)
   th/TH_TyInstWhere2.run             TH_TyInstWhere2 [exit code non-0] (ext-interp)
   th/ClosedFam1TH.run                ClosedFam1TH [exit code non-0] (ext-interp)
   th/TH_Roles3.run                   TH_Roles3 [exit code non-0] (ext-interp)
   th/T7477.run                       T7477 [exit code non-0] (ext-interp)
   th/T8884.run                       T8884 [exit code non-0] (ext-interp)
   th/T9262.run                       T9262 [exit code non-0] (ext-interp)
   th/T9692.run                       T9692 [exit code non-0] (ext-interp)
   th/T8953.run                       T8953 [exit code non-0] (ext-interp)
   th/T9738.run                       T9738 [exit code non-0] (ext-interp)
   th/T10620.run                      T10620 [exit code non-0] (ext-interp)
   th/T10828.run                      T10828 [exit code non-0] (ext-interp)
   th/T11721_TH.run                   T11721_TH [exit code non-0] (ext-interp)
   th/T11797.run                      T11797 [exit code non-0] (ext-interp)
   th/T8761.run                       T8761 [exit code non-0] (ext-interp)
   th/T12478_1.run                    T12478_1 [exit code non-0] (ext-interp)
   th/T12646.run                      T12646 [exit code non-0] (ext-interp)
   th/T13642.run                      T13642 [exit code non-0] (ext-interp)
   th/T14060.run                      T14060 [exit code non-0] (ext-interp)
   th/T15502.run                      T15502 [exit code non-0] (ext-interp)
   th/TH_implicitParams.run           TH_implicitParams [exit code non-0] (ext-interp)
   th/T15738.run                      T15738 [exit code non-0] (ext-interp)
   th/T15792.run                      T15792 [exit code non-0] (ext-interp)
   th/T15845.run                      T15845 [exit code non-0] (ext-interp)

Change History (6)

comment:1 Changed 8 weeks ago by Ben Gamari <ben@…>

In 5499f12/ghc:

testsuite: Mark th tests as broken in ext-interp way in LLVM build flavours

This is due to the failures documented in #16087. The condition here could be
improved as it matches on `BUILD_FLAVOUR` instead of looking at the compiler
flags. However, it's better than nothing and I hope we will be able to fix these
issues before long.

comment:2 Changed 7 weeks ago by osa1

Milestone: 8.8.18.10.1

Bumping milestones of low-priority tickets.

comment:3 Changed 3 weeks ago by bgamari

Well this is mysterious. I have observed these tests unexpectedly passing on CI. Quite mysterious.

comment:4 Changed 2 weeks ago by bgamari

I tried running a test locally where I only observed the following failures:

=====> TH_repPrim(ext-interp) 3 of 11 [0, 2, 0]
cd "th/TH_repPrim.run" &&  "/mnt/work/ghc/ghc/inplace/bin/ghc-stage2" -c TH_repPrim.hs -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output -XTemplateHaskell -package template-haskell -fexternal-interpreter -v0
Compile failed (exit code 1) errors were:
AppE (ConE GHC.Types.I#) (LitE (IntPrimL 20))
GHC.Types.I# 20#
AppE (ConE GHC.Types.W#) (LitE (WordPrimL 32))
GHC.Types.W# 32##

TH_repPrim.hs:23:29: error:
    • Exception when trying to run compile-time code:
        ghc-stage2: ghc-iserv terminated (-11)
      Code: do e <- [| F# 12.3# |]
               runIO $ putStrLn $ show e
               runIO $ putStrLn $ pprint e
               ....
    • In the untyped splice:
        $(do e <- [| F# 12.3# |]
             runIO $ putStrLn $ show e
             runIO $ putStrLn $ pprint e
             runIO $ hFlush stdout
             ....)

*** unexpected failure for TH_repPrim(ext-interp)

=====> TH_repPrim2(ext-interp) 4 of 11 [0, 3, 0]
cd "th/TH_repPrim2.run" &&  "/mnt/work/ghc/ghc/inplace/bin/ghc-stage2" -c TH_repPrim2.hs -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output -XTemplateHaskell -package template-haskell -fexternal-interpreter -v0
Compile failed (exit code 1) errors were:
LitE (IntPrimL 20)
20#
LitE (WordPrimL 32)
32##

TH_repPrim2.hs:23:29: error:
    • Exception when trying to run compile-time code:
        ghc-stage2: ghc-iserv terminated (-11)
      Code: do e <- [| 12.3# |]
               runIO $ putStrLn $ show e
               runIO $ putStrLn $ pprint e
               ....
    • In the untyped splice:
        $(do e <- [| 12.3# |]
             runIO $ putStrLn $ show e
             runIO $ putStrLn $ pprint e
             runIO $ hFlush stdout
             ....)

*** unexpected failure for TH_repPrim2(ext-interp)

=====> T11721_TH(ext-interp) 5 of 11 [0, 4, 0]
cd "th/T11721_TH.run" &&  "/mnt/work/ghc/ghc/inplace/bin/ghc-stage2" -c T11721_TH.hs -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output -XTemplateHaskell -package template-haskell -fexternal-interpreter -v0
Compile failed (exit code 1) errors were:

T11721_TH.hs:15:3: error:
    • Exception when trying to run compile-time code:
        ghc-stage2: ghc-iserv terminated (-11)
      Code: do let rightOrder :: [TyVarBndr] -> Bool
                   ....
               TyConI (DataD _ _ _ _ [ForallC con_tvbs1 _ _] _) <- reify ''T
               DataConI _ (ForallT con_tvbs2 _ _) _ <- reify 'MkT
               ....
    • In the untyped splice:
        $(do let rightOrder :: [TyVarBndr] -> Bool
                 rightOrder [KindedTV b _, KindedTV a _]
                   = nameBase b == "b" && nameBase a == "a"
                 rightOrder _ = False
             TyConI (DataD _ _ _ _ [ForallC con_tvbs1 _ _] _) <- reify ''T
             DataConI _ (ForallT con_tvbs2 _ _) _ <- reify 'MkT
             if rightOrder con_tvbs1 && rightOrder con_tvbs2 then
                 [| () |]
             else
                 fail "T11721_TH failed")

*** unexpected failure for T11721_TH(ext-interp)

=====> T15502(ext-interp) 6 of 11 [0, 6, 0]
cd "th/T15502.run" &&  "/mnt/work/ghc/ghc/inplace/bin/ghc-stage2" -c T15502.hs -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -rtsopts -fno-warn-missed-specialisations -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret -Werror=compat -dno-debug-output -XTemplateHaskell -package template-haskell -fexternal-interpreter -v0 -ddump-splices -dsuppress-uniques
Compile failed (exit code 1) errors were:

T15502.hs:7:16: error:
    • Exception when trying to run compile-time code:
        {handle: <file descriptor: 11>}: GHCi.Message.remoteCall: end of file
      Code: lift (toInteger (maxBound :: Int) + 1)
    • In the untyped splice: $(lift (toInteger (maxBound :: Int) + 1))

*** unexpected failure for T15502(ext-interp)

comment:5 Changed 2 weeks ago by bgamari

I'm going to look a bit harder at T15502. The test is quite simple:

main = print ( $( lift (toInteger (maxBound :: Int) + 1) )
             , $( lift (minBound :: Int) )
             )

GHC falls over when evaluating the first splice. If I comment it out compilation finishes without crashing. Consequently, the minimal reproducer is:

{-# LANGUAGE TemplateHaskell #-}

import Language.Haskell.TH.Syntax  (Lift(lift))

main = print $( lift (toInteger (maxBound :: Int) + 1) )

compiled with -fexternal-interpreter by a GHC compiled with -fllvm.

Indeed, this is also easily reproducible with ghci:

inplace/bin/ghc-stage2 -fexternal-interpreter --interactive
GHCi, version 8.7.20190128: https://www.haskell.org/ghc/  :? for help
Prelude> print $ toInteger (maxBound :: Int) + 1
ghc-stage2: ghc-iserv terminated (-11)
Leaving GHCi.

The backtrace after the crash reliably looks like:

>>> x/80a $rbp
0x4200185e48:	0x8000000000000000	0x1b59860 <stg_upd_frame_info$def>
0x4200185e58:	0x420001fad8	0x41de6980
0x4200185e68:	0x420001fad8	0x41677621
0x4200185e78:	0x40c63dd8	0x420001fad8
0x4200185e88:	0x41068ca1	0x40c64290
0x4200185e98:	0x1b59860 <stg_upd_frame_info$def>	0x4200033518
0x4200185ea8:	0x40b5c330	0x4165e490
0x4200185eb8:	0x4200033518	0x40b6f020
0x4200185ec8:	0x4165e490	0x4200033518
0x4200185ed8:	0x41068c7a	0x40a02560
0x4200185ee8:	0x420001fa80	0x1b59040 <stg_maskAsyncExceptionszh_ret_info$def>
0x4200185ef8:	0x1b59490 <stg_catch_frame_info$def>	0xc
0x4200185f08:	0x42000334aa	0x40cb3790
0x4200185f18:	0x420002e879	0x4200032512
0x4200185f28:	0x420002b7d0	0x420003301a
0x4200185f38:	0x1b59490 <stg_catch_frame_info$def>	0xc
0x4200185f48:	0x4200032002	0x40cb3790
0x4200185f58:	0x420002e879	0x4200030082
0x4200185f68:	0x420001fa18	0x4200031122
0x4200185f78:	0x1b58f00 <stg_unmaskAsyncExceptionszh_ret_info$def>	0xf38490 <cluU_info$def>
0x4200185f88:	0x1b59490 <stg_catch_frame_info$def>	0x0
0x4200185f98:	0x420002e7ca	0xf38570 <clv8_info$def>
0x4200185fa8:	0x1b59490 <stg_catch_frame_info$def>	0x0
0x4200185fb8:	0x1e02eca <rk39_closure$def+2>	0xf386c8 <clvj_info$def>
0x4200185fc8:	0x1b59070 <stg_maskUninterruptiblezh_ret_info$def>	0xf388d0 <clwA_info$def>
0x4200185fd8:	0x420002e580	0x1b59490 <stg_catch_frame_info$def>
0x4200185fe8:	0x4	0x1eaec12 <base_GHCziConcziSync_forkIO2_closure+2>
0x4200185ff8:	0x1b5cad0 <stg_stop_thread_info$def>	0x1b56b30 <stg_ARR_WORDS_info$def>
0x4200186008:	0x8000	0x10000000113
0x4200186018:	0x23000000000000	0x2000000000000000
0x4200186028:	0x4	0x4200186158
0x4200186038:	0x41068ca0	0x4163b8b8
0x4200186048:	0x420002f100	0x1b13e20 <ghczmprim_GHCziTypes_Izh_con_info$def>
0x4200186058:	0x8000	0x1b13e70 <ghczmprim_GHCziTypes_ZC_con_info$def>
0x4200186068:	0x4200186189	0x1fd7e11 <ghczmprim_GHCziTypes_ZMZN_closure+1>
0x4200186078:	0xe51ac8 <s1mVR_info$def>	0x42001861b5
0x4200186088:	0x11953a0 <s7aK_info$def>	0x1def943 <ghcizm8zi7_GHCiziMessage_zdfBinaryEvalStatuszu3_closure+3>
0x4200186098:	0x1def909 <ghcizm8zi7_GHCiziMessage_zdfBinaryEvalStatuszu6_closure+1>	0x1def8fa <ghcizm8zi7_GHCiziMessage_zdfBinaryEvalStatuszu7_closure+2>
0x42001860a8:	0x119c158 <binaryzm0zi8zi6zi0_DataziBinaryziGetziInternal_Partial_con_info$def>	0x42001852e9
0x42001860b8:	0x1195080 <s7aS_info$def>	0x1b13e70 <ghczmprim_GHCziTypes_ZC_con_info$def>

comment:6 Changed 10 days ago by int-index

Data point: another spontaneous pass https://gitlab.haskell.org/ghc/ghc/-/jobs/22691

Note: See TracTickets for help on using tickets.