Ticket #2202 (closed bug: fixed)

Opened 5 years ago

Last modified 5 years ago

type error causes type checker stack overflow

Reported by: chiral Owned by: chak
Priority: normal Milestone: 6.10.1
Component: Compiler (Type checker) Version: 6.8.2
Keywords: Cc: bdonlan@…
Operating System: Other Architecture: Other
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

The following code causes

*** Exception: stack overflow

during type checking. I've tried to whittle the test case down, this may not be minimal. The (Ord a) instances and the unused vertexID member of the datatype seem to be necessary, otherwise the infinite type is correctly caught. Does not occur under 6.6.1

module GHCBug(
  MeshVertex(..)
  ) where

data (Ord a) => MeshVertex a b = MeshVertex {
  vertexID         :: a,
  vertexChildren   :: [a]
  } deriving (Show)

split :: (Ord a)   =>
  a                ->
  [MeshVertex a b] ->
  [MeshVertex a b]
split a m = let
    av      = head m
    newVTs  = preSplit a m
    av'     = av { vertexChildren = newVTs }
    newMVs  = av' : m
    newMesh = newMVs
  in newMesh

preSplit :: (Ord a) =>
  a                 ->
  [MeshVertex a b]  ->
  [MeshVertex a b]
preSplit a m = preSplit a $ split a m

Change History

Changed 5 years ago by chak

  • owner set to chak
  • os changed from MacOS X to Other
  • architecture changed from x86 to Other

Changed 5 years ago by simonpj

  • cc bdonlan@… added
  • difficulty set to Unknown

I believe this bug from Bryan Donlan is closely related. (He sent the report by email; I don't think there's a ticket for it.) I propose not to chase it down until Manuel has fixed this ticket (he is on the job). Then let's re-investigate.

Simon

I've found a case where GHC will hang (consuming more and more memory) when it should report an occurs check error. The test case is at  http://fushizen.net/~bd/kaos-ghc-loop.tgz - the error in question is that the arguments in the StateT instance for HOLift are reversed like so:

diff --git a/src/Kaos/KaosM.hs b/src/Kaos/KaosM.hs
index ec4e69a..268250a 100644
--- a/src/Kaos/KaosM.hs
+++ b/src/Kaos/KaosM.hs
@@ -88,7 +88,7 @@ genlift' unbox box f m = box $ \s -> f (unbox m s)
 class HOLift m b | m -> b where
     genlift :: (forall r'. b r' -> b r') -> (forall r. m r -> m r)

-instance HOLift m (StateT s m) where
+instance HOLift (StateT s m) m where
     genlift = genlift' runStateT StateT

 instance (HOLift m b, KaosDiagM r b) => KaosDiagM r m where

I'm using GHC 6.8.2 on ubuntu hardy.

Bryan Donlan

Changed 5 years ago by igloo

  • milestone set to 6.8.3

Changed 5 years ago by igloo

  • milestone changed from 6.8.3 to 6.10.1

Changed 5 years ago by chak

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

All fine with the new solver.

Note: See TracTickets for help on using tickets.