Ticket #1031 (closed merge: fixed)

Opened 2 years ago

Last modified 2 weeks ago

ghc 6.6 impossible happened

Reported by: guest Assigned to: igloo
Priority: normal Milestone: 6.6.1
Component: Compiler Version: 6.6
Severity: normal Keywords:
Cc: ahey@iee.org Difficulty: Unknown
Test Case: dsrun014 Architecture: Unknown/Multiple
Operating System: Unknown/Multiple

Description

ghc-6.6: panic! (the 'impossible' happened)
  (GHC version 6.6 for i386-unknown-linux):
        cgPanic
    tpl{v sVs} [lid]
    static binds for:
    main:Util.RWS.runRWS'{v rpz} [gid]
    main:Util.RWS.$f4{v rv4} [gid]
    main:Util.RWS.$f5{v rva} [gid]
    local binds for:
    SRT label main:Util.RWS.$f3{v ruN}_srt

the file which caused it is:

-- modification of Control.Monad.RWS to make it strict in its fields, as well as use unboxed tuples internally

module Util.RWS (
	RWS,
	module Control.Monad.Reader,
	module Control.Monad.Writer,
	module Control.Monad.State,
  ) where

import Prelude

import Control.Monad
import Control.Monad.Fix
import Control.Monad.Trans
import Control.Monad.Reader
import Control.Monad.Writer
import Control.Monad.State
import Data.Monoid



newtype RWS r w s a = RWS { runRWS' :: r -> s -> (# a, s, w #) }

runRWS x r s = case runRWS' x r s of
    (# a, b, c #) -> (a,b,c)

instance Functor (RWS r w s) where
	fmap f m = RWS $ \r s -> let
		(# a, s', w #) = runRWS' m r s
		in s' `seq` w `seq` (# f a, s', w #)

instance (Monoid w) => Monad (RWS r w s) where
	return a = RWS $ \_ s -> (# a, s, mempty #)
	m >>= k  = RWS $ \r s -> case runRWS' m r s of
		(# a, s',  w #) -> case runRWS' (k a) r s' of
                    (# b, s'', w' #) -> let w'' = w `mappend` w'
                        in w'' `seq` (# b, s'', w'' #)

--instance (Monoid w) => MonadFix (RWS r w s) where
--	mfix f = RWS $ \r s -> let (a, s', w) = runRWS (f a) r s in (a, s', w)

instance (Monoid w) => MonadReader r (RWS r w s) where
	ask       = RWS $ \r s -> (# r, s, mempty #)
	local f m = RWS $ \r s -> let r' = f r in r' `seq` runRWS' m r' s

instance (Monoid w) => MonadWriter w (RWS r w s) where
	tell   w = RWS $ \_ s -> (# (), s, w #)
	listen m = RWS $ \r s -> case runRWS' m r s of
            (# a, s', w #) -> (# (a, w), s', w #)
	pass   m = RWS $ \r s -> case runRWS' m r s of
		(# (a, f), s', w #) -> let w' = f w in w' `seq` (# a, s', w' #)

instance (Monoid w) => MonadState s (RWS r w s) where
	get   = RWS $ \_ s -> (# s, s, mempty #)
	put s = RWS $ \_ _ -> s `seq` (# (), s, mempty #)
                                                               

Attachments

BugDemo.zip (37.1 kB) - added by simonpj on 01/03/07 06:00:41.
Adrian Hey's repo case

Change History

11/28/06 18:25:53 changed by guest

this bug is from John Meacham <john@repetae.net>

11/29/06 03:41:26 changed by simonpj

  • owner set to simonpj.

I've diagnosed this (note to self: ~/tmp/Foo6.hs).

It's a tricky interaction of seq and unboxed tuples. I'm about to go away for 10 days; I'll look at it when I get back, unless it's a show-stopper for you.

Simon

12/03/06 15:23:02 changed by guest

using bang patterns to enfore strictness rather than 'seq' seems to work around the problem. -John

01/03/07 06:00:02 changed by simonpj

  • cc set to ahey@iee.org.

Adrian Hey writes: I seem to have hit this problem. (I think, at least I'm getting a very similar incomprehensible error message :-)

I tried using bang patterns instead of seq like this:

let a0_ = f a0 a in a0_ `seq` (# l,hl,a0_,r,hr #)

becomes ..

let !a0_ = f a0 a in (# l,hl,a0_,r,hr #)

but I still get the same error.

The attachment should show the problem (in Windows using Build.BAT). The problem occurs in the HSet module (and maybe others).

BTW, regarding the urgency of this, a solution is not particularly urgent for me as it's part of a generalised tries lib which probably needs at least another months work or so before it's ready for prime time, and seeing as at the end of the week I'm going away until end of Feb it probably won't be a real show stopper until about April (and even then it'll only stop a lib that noone is currently dependent on, not even me :-)

01/03/07 06:00:41 changed by simonpj

  • attachment BugDemo.zip added.

Adrian Hey's repo case

01/24/07 17:00:33 changed by igloo

  • milestone set to 6.6.1.

03/16/07 08:21:23 changed by simonpj

  • testcase set to dsrun014.
  • owner changed from simonpj to igloo.
  • type changed from bug to merge.

OK I've fixed this. Please merge to 6.6 branch

Simon

Fri Mar 16 15:17:12 GMT 2007 simonpj@microsoft.com

  • Desugar applications of 'seq' specially; fix Trac #1031

03/16/07 18:25:04 changed by igloo

  • status changed from new to closed.
  • resolution set to fixed.

Merged, along with

Establish the CoreSyn let/app invariant
simonpj@microsoft.com**20070205173150

09/30/08 08:40:05 changed by simonmar

  • architecture changed from Unknown to Unknown/Multiple.

09/30/08 08:51:11 changed by simonmar

  • os changed from Unknown to Unknown/Multiple.