Cabal test panic CallStack

$ cabal v2-test

panic! read @TestSuiteLog ""
CallStack (from HasCallStack):
  error, called at libraries/Cabal/Cabal/src/Distribution/Simple/Test/LibV09.hs:133:34 in Cabal-3.8.1.0:Distribution.Simple.Test.LibV09
Error: cabal: Tests failed for test:test-text from replace-megaparsec-2.0.0.0.

How can I get some better callstack information about this error?

1 Like

Trying some flags from Debugging - HaskellWiki in the .cabal file,

library
  ghc-options:         -Wall -debug -g2 -prof

test-suite test-text
  ghc-options:         -Wall -debug -g2 -prof -fprof-auto +RTS -xc

now I get this build error

$cabal v2-test

src/Replace/Megaparsec/Internal/ByteString.hs:19:8: error:
    Failed to load dynamic interface file for Prelude:
    Bad interface file: /nix/store/jflrijifpjbl8bh4vcl3fxhzfiv26qdf-ghc-9.4.3/lib/ghc-9.4.3/base-4.17.0.0/Prelude.p_dyn_hi
        /nix/store/jflrijifpjbl8bh4vcl3fxhzfiv26qdf-ghc-9.4.3/lib/ghc-9.4.3/base-4.17.0.0/Prelude.p_dyn_hi: openBinaryFile: does not exist (No such file or directory)
1 Like

Are you tied to using the detailed-0.9 test suite interface? It seems to be a barely maintained obsolete dead end of Cabal history. (Compare e.g. `detailed-0.9` and `--enable-coverage` fail together · Issue #7856 · haskell/cabal · GitHub).

If you are, I think I’d try to figure out (maybe via debug logs?) what test executable is being called, and try to run that by hand. The relevant part of Cabal code is cabal/LibV09.hs at a5ddb14e0a648ea8608d0de987c417cb17c16441 · haskell/cabal · GitHub.

2 Likes

Oh it turns out there’s Cabal issue where a test fails with this same error on macOS: PackageTests/Regression/T4270/setup.test.hs fails on MacOS on GHC 8.0.2 · Issue #8028 · haskell/cabal · GitHub. Do you happen to be seeing this on macOS?

From looking at the code (cabal/LibV09.hs at a5ddb14e0a648ea8608d0de987c417cb17c16441 · haskell/cabal · GitHub), it seems likely that this is a race between the child test process’s write to a file and Cabal’s subsequent read of that file. (This mode of communication via writing log file names to files seems not particularly robust.)

1 Like

Thanks for the advice about detailed-0.9 @robx . I switched to exitcode-stdio-1.0 with HSpec. That gave me a slightly better error message:

test: internal error: Oops!  Entered absent arg Arg: $dOrd
Type: Ord e
In module `Replace.Megaparsec'
    (GHC version 9.4.3 for x86_64_unknown_linux)
    Please report this as a GHC bug:  https://www.haskell.org/ghc/reportabug

Then I upgraded GHC from v9.4.3 to v9.4.4 and the error went away and the whole test suite passed. So I guess it was some GHC problem which was fixed in v9.4.4.

Maybe this one Oops! Entered absent arg Arg: lvl (#22475) · Issues · Glasgow Haskell Compiler / GHC · GitLab from the change log 2.1. Version 9.4.4 — Glasgow Haskell Compiler 9.4.4 User's Guide

2 Likes