Opened 10 years ago

Closed 10 years ago

Last modified 10 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: None/Unknown Test Case: tc226
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

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:  http://www.haskell.org/ghc/reportabug

Attachments (1)

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

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by rashakil

Attachment: Foo.hs added

Source file, listed in description already.

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

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

comment:2 Changed 10 years ago by igloo

Milestone: 6.6.2

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

comment:3 Changed 10 years ago by simonpj

Resolution: fixed
Status: newclosed
Test Case: 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.

Simon

comment:4 Changed 10 years ago by simonmar

Milestone: 6.6.26.8.1
Note: See TracTickets for help on using tickets.