Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#1255 closed bug (fixed)

UNPACKing a !Foo with newtype Foo = (Ptr Foo) causes the impossible

Reported by: rashakil Owned by:
Priority: normal Milestone: 6.8.1
Component: Compiler Version: 6.6
Keywords: UNPACK unbox newtype Ptr Cc:
Operating System: Linux Architecture: x86
Type of failure: Test Case: tc226
Blocked By: Blocking:
Related Tickets: Differential Rev(s):


Here is the code that causes the error. The strictness annotation and the unboxing of the field is necessary to cause the error. Experimentation shows that the error happens regardless of the number of named fields. I first found this when I tried using ":: {-# UNPACK #-} !X.GC" somewhere.

{-# OPTIONS_GHC -funbox-strict-fields #-}

module Foo where

import Foreign.Ptr

newtype  Bar        = Bar (Ptr Bar) -- Must be Bar inside.

data  Gah           = Gah { baaz  :: !Bar }

-- Alternately, disable -funbox-strict-fields and use {-# UNPACK #-},
-- and the impossible still happens.

Here's the error message.

$ ghc --make Foo -v
Glasgow Haskell Compiler, Version 6.6, for Haskell 98, compiled by GHC version 6.6
Using package config file: /usr/lib/ghc-6.6/package.conf
wired-in package base mapped to base-2.0
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0
wired-in package template-haskell mapped to template-haskell-2.0
Hsc static flags: -static
*** Chasing dependencies:
Chasing modules from: Foo.hs
Stable obj: []
Stable BCO: []
compile: input file Foo.hs
Created temporary directory: /tmp/ghc3424_0
*** Checking old interface for main:Foo:
[1 of 1] Compiling Foo              ( Foo.hs, Foo.o )
*** Parser:
*** Renamer/typechecker:
*** Desugar:
    Result size = 0
*** Simplify:
    Result size = 0
*** Tidy Core:
*** Deleting temp files:
Deleting: /tmp/ghc3424_0/ghc3424_0.s
Warning: deleting non-existent /tmp/ghc3424_0/ghc3424_0.s
*** Deleting temp dirs:
Deleting: /tmp/ghc3424_0
ghc-6.6: panic! (the 'impossible' happened)
  (GHC version 6.6 for i386-unknown-linux):
	dataConWorkId main:Foo.Bar{d rfa}

Please report this as a GHC bug:

Attachments (1)

Foo.hs (295 bytes) - added by rashakil 9 years ago.
Source file, listed in description already.

Download all attachments as: .zip

Change History (5)

Changed 9 years ago by rashakil

Source file, listed in description already.

comment:1 Changed 9 years ago by stefanor@…>

Datapoint: This works correctly (well, -dcore-lint clean) on HEAD with the new newtype system.

comment:2 Changed 9 years ago by igloo

  • Milestone set to 6.6.2

6.6 branch is broken, HEAD seems to compile fine (as noted by Stefan).

comment:3 Changed 8 years ago by simonpj

  • Resolution set to fixed
  • Status changed from new to closed
  • Test Case set to tc226

There is a palpable bug in here, which is already fixed in the HEAD. But I must have forgotten to transfer the change to the 6.6 branch. I've done so now, in case we ever release 6.6.2.

Thanks for the report.


comment:4 Changed 8 years ago by simonmar

  • Milestone changed from 6.6.2 to 6.8.1
Note: See TracTickets for help on using tickets.