Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion failure but nobody notices because assertions are off by default #106

Open
nh2 opened this issue Jun 15, 2024 · 2 comments
Open

Comments

@nh2
Copy link
Member

nh2 commented Jun 15, 2024

I'm building ghc-events as part of static-haskell-nix's CI, where sometimes I build with -O0.

An assertion appears:

test-versions: Assertion failed
CallStack (from HasCallStack):
  assert, called at src/GHC/RTS/Events/Binary.hs:822:5 in ghc-events-0.19.0.1-863kLHKqkAq5pQOjpORL0w:GHC.RTS.Events.Binary

That's this one:

assert (fromIntegral payloadLen ==
(sum
[ 8 -- tickyCtrDefId
, 2 -- tickyCtrDefArity
, textByteLen tickyCtrDefKinds
, textByteLen tickyCtrDefName
, 8 -- tickyCtrInfoTbl
, maybe 0 textByteLen tickyCtrJsonDesc
]))

I tested also with stack test on a stack.yaml with this config:

resolver:
  url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/25.yaml
packages:
- .

As documented in assert, it's disabled on -O, which cabal enables by default.

So probably nobody noticed that.

I recommend setting either

  ghc-options:      -Wall -fno-ignore-asserts

if assertions should be used in code, or not using assert.

@Mikolaj
Copy link
Member

Mikolaj commented Jun 15, 2024

I'm all for assertions, but people usually don't like the idea. We should at least enable them in CI. And fix whichever are failing...

@nh2
Copy link
Member Author

nh2 commented Jun 15, 2024

but people usually don't like the idea

People don't want assertions in production code that make it 100x slower.

The checks implemented in that file seem to be simple integer comparisons, fast enough to enable without noticing anything.

So I think those should just be error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants