Skip to content

Segfault due to levity polymorphism of mkWeak#

This code segfaults:

{-# LANGUAGE MagicHash, UnboxedTuples #-}
import GHC.Prim
import GHC.Types

main = do
    let local = ()
    let null = 0## :: Word#
    let triple = (# local, null, null #)
    IO (\s -> case mkWeakNoFinalizer# triple () s of (# s, r #) -> (# s, () #))

The problem is that mkWeakNoFinalizer# has a levity polymorphic type for its first argument, but the implementation really requires the first argument to be a pointer.

Trac metadata
Trac field Value
Version 8.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC goldfire
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information