Known GHC Bugs and Problems

<<<<<<< ghc-bugs.html This is the FEB (Frequently Encountered Bugs) page for the Glasgow Haskell Compiler, suggesting solutions/workarounds to commonly encountered bugs with GHC (versions 0.29 ["old" compiler for Haskell 1.2] and 2.01 ["new" compiler for Haskell 1.3]).

You also wish to consult the archive of the glasgow-haskell-bugs mailing list...

Contents

=======

This is the FEB (Frequently Encountered Bugs) page for the Glasgow Haskell Compiler, suggesting solutions/workarounds to commonly encountered bugs with GHC (versions 0.29 onward).

You may also wish to consult the archive of the glasgow-haskell-bugs mailing list...

The latest source+binary release of the 1.4 compiler, is version 2.02. A source-only minor release, 2.07, is available which fixes up most of the reported problems with 2.02 (and subsequent snapshot releases).

Contents:

In general, bugs in later versions (higher up this list) also occur in earlier versions; but bugs in earlier versions are fixed in later versions unless otherwise noted.

GHC 2.08 bugs and workarounds

Typechecking bug with overloaded constructor arguments.

>>>>>>> 1.41
<<<<<<< ghc-bugs.html

Building 0.29 breaks on compiling PreludeIO_p.hc

=======

GHC 2.07 bugs and workarounds

happy/src/Parser.hs won't compile with ghc-0.29

Can't access () when importing the Prelude qualified

Can't compile happy/src/Main.lhs with -O

GHC always recompiles modules, even if nothing has changed

seq doesn't work with the native code generator


GHC 2.05 bugs and workarounds

hsp shortcoming

Crash when discarding polymorphic case

Crash in absApply

Compiling prelude libraries on x86 machines

x86 backend -monly-n-regs bug

Big tuples

Fails on 1M threads

We havn't investigated this yet [mid Aug 97].

Interface file parse error for ccalls

Record construction for overloaded data types

Misleading error message for guards

Missed type error for rank 2 types

compiling with ghc-0.29 -O

missing functions from List

Exporting (->) instances


GHC 2.04 bugs and workarounds

"->" isn't an instance of Eval


Specialiser doesn't work


Same field in two constructors of data decl


Exporting qualified imports


Trouble compiling up ghc-2.04-src.tar.gz


Compiling prelude libraries on x86 machines


GHC 2.03 bugs and workarounds

Function arrow not exported from Prelude


Two record bugs


Bug in Semaphore.signalQSemN


Turning off incomplete pattern match warnings is not possible


Compiler loops on type error


Cannot link code using CPUTime


Undefined symbols when using -prof -auto-all


Cannot build user documentation



GHC 2.02 bugs and workarounds

Duplicate definitions in instances


Do notation for lists


Unqualified Prelude names aren't in scope


Multiple type signatures for mutually recursive overloaded functions don't work


Duplicate top-level declarations not detected.


Wrong type for seq


make install breaks when creating directories


Unreported symbols when linking -concurrent code


Converting profile data with hp2psfails


Compiler panic when compiling profiling code


GHC for Win32: linker reports unresolved symbol VirtualProtect


Cannot use -syslib hbc under Linux


What? Perfectly Reasonable Haskell programs don't compile anymore


Checksum errors when un-tar'ing the 2.02 distribution


Help! I cannot find the function maybe


The compiler cannot find a Glasgow extension like unboxed types


Strictness annotations in data types aren't parsed correctly


Using letrec as identifier does not work


Installation fails during copying of library files


Empty comment ending the file breaks the parser


>>>>>>> 1.41

GHC 0.29 bugs and workarounds

Using dupChan does not work(2.01 and 0.29)

Using dupChan does not work (2.01 and 0.29) Symptom: Programming with the Channel abstraction (using the concurrent extensions), multiple readers cannot share a channel properly (even though dupChan is used), one of them ends up monopolises the Channel. There's a bug in the code for Channel.getChan, as it does not release the lock on the items in the channel it reads. The fix is simple, change one line in the definition of getChan:
 getChan :: Chan a -> IO a
 getChan (Chan read write)
  = takeMVar read            >>= \ rend ->
    -- WRONG: takeMVar rend  >>= \ res@(ChItem val new_rend) ->
    readMVar rend            >>= \ res@(ChItem val new_rend) ->
    putMVar read new_rend    >>
    return val
Thanks to Meurig Sage <meurig@dcs.gla.ac.uk> for reporting the problem and contributing the fix.

Foreign objects prematurely released

There's a bug in 0.29 that causes Foreign objects to be finalised prematurely. To fix problem this you need to recompile the compiler sources with the following patch applied:
*** ghc/compiler/PrimKind.lhs-old	1996/05/15 17:35:06
--- ghc/compiler/PrimKind.lhs	1997/08/07 20:42:19
***************
*** 104,109 ****
  isFollowableKind ArrayKind  	= True
  isFollowableKind ByteArrayKind 	= True
! -- why is a MallocPtr followable? 4/96 SOF
! --isFollowableKind MallocPtrKind = True
  
  isFollowableKind StablePtrKind  = False
--- 104,113 ----
  isFollowableKind ArrayKind  	= True
  isFollowableKind ByteArrayKind 	= True
! -- why is a ForeignObj followable? 4/96 SOF
! --
! -- A: they're followable because these objects
! -- should be lugged around by the storage manager
! -- (==> we need to generate code that identify them as such) -- 3/97 SOF
! isFollowableKind ForeignObjKind = True
  
  isFollowableKind StablePtrKind  = False

Assembler trouble under IRIX

The output from GHC-0.26 under mips-sgi-irix is not liked by the latest versions of GCC and GAS (i.e., 2.7.2 and 2.6):


    % ghc -v hello.hs
    /usr/tmp/ghc10322.s:44: Error: Can not represent relocation in this object file format
    /usr/tmp/ghc10322.s:46: Error: Can not represent relocation in this object file format
    [..]

(or variations thereof). For now, try sticking with an older version of GAS (2.5.2 has been used with success)



HSC can't find getrusage under Solaris 2.4

Symptom:

Running GHC as it comes out of the binary distribution fails with the message

    ld.so.1: hsc: fatal: relocation error: symbol not found:
    getrusage: referenced in hsc

under Solaris 2.4.

Solution:

Preferably, upgrade to Solaris 2.5 (this problem is specific to Solaris 2.4).

Alternatively, create a dummy definition of getrusage and turn it into a shared object (for use with hsc) and add it to the runtime-system library. Jon Mountjoy gives a recipe for this glorious hack.



Problems with the GLASGOW_HASKELL_ROOT environment variable

Symptom:

After boldly hacking the ghc driver script and setting the GLASGOW_HASKELL_ROOT variable any compilation fails with the message

    GLASGOW_HASKELL_ROOT environment variable is set;
    But can't untangle /local/fp/lib/ghc/2.01/i386-unknown-linux.
    (Installation error)

Solution:

Don't do it! Set the variables

    $InstLibDirGhc  
    $InstDataDirGhc 
<<<<<<< ghc-bugs.html directly to the directories containing platform-dependent and platform-independent GHC support files, respectively. Using GLASGOW_HASKELL_ROOT is an officially Plain Bad Idea.

getCPUTime doesn't work poperly for ghc-2.01 (SunOs 4, Solaris 2.x)

Symptom:

Calls to getCPUTime in ghc-2.01 return strange (and very unlikely) results (see bug report).

Solution:

Patched versions of the ghc library for a standard, profiling and concurrent setup are available from the Glasgow FTP server:

 ftp://www.dcs.gla.ac.uk/pub/haskell/glasgow/working/libHSghc.a-ghc-2.01-sparc-sun-solaris2
 ftp://www.dcs.gla.ac.uk/pub/haskell/glasgow/working/libHSghc_p.a-ghc-2.01-sparc-sun-solaris2
 ftp://www.dcs.gla.ac.uk/pub/haskell/glasgow/working/libHSghc_mc.a-ghc-2.01-sparc-sun-solaris2



The profiling setup of GHC 2.01 hates PreludeGlaST

Symptom:

When compiling a program that has an import PreludeGlaST with GHC 2.01 and profiling turned on (-prof) an error message like this appears:

ld:
/usr/haskell/ghc-2.01/lib/ghc/2.01/sparc-sun-sunos4/libHSrts_p.a(StgStartup.p_o):
__regPreludeGlaST: multiply defined

Solution:

Pick one of the following:


Hans-Wolfgang Loidl <hwloidl@dcs.glasgow.ac.uk>
=======

directly to the directories containing platform-dependent and platform-independent GHC support files, respectively. Using GLASGOW_HASKELL_ROOT is an officially Plain Bad Idea.

Profiling build `not available' on Solaris

Symptom:

When trying the pre-built profiling stuff for sparc-sun-solaris2, you may get:

   % ghc-0.29 -prof Main.hs
   ghc-0.29: a `profiling' "build" is not available with your GHC setup.
   (It was not configured for it at your site.)

Solution:

Simply edit your driver (ghc-0.29), around about line 207, to read:

%BuildAvail	= ('',	    '-build-normal-defined',
		   '_p',    '-build-p-defined', # NB: this line here
		   ...



Building 0.29 breaks on compiling PreludeIO_p.hc

Symptom:

Utter misery when building 0.29 a non-sequential (i.e., profiling, concurrent etc.) prelude from sources:

foo% pwd;make
/ghc-BUILDS/0.29/ghc/lib
[....]
../../ghc/driver/ghc -c   -hi-diffs -dcore-lint -link-chk  -iprelude:glaExts   
-dcore-lint -fshow-pragma-name-errs -fshow-import-specs -fomit-default-instance-methods       
-cpp -fglasgow-exts -genSPECS -DUSE_FOLDR_BUILD -D__OVERLAPPING_INSTANCES__
-H40m -prelude -fno-implicit-prelude -fomit-reexported-instances 
-split-objs PIO -ohi prelude/PreludeIO.hi -fno-omit-reexported-instances 
'-#include"stgio.h"' -hisuf _p.hi  -O  -prof -GPrelude prelude/PreludeIO_p.hc 
-odir prelude/PreludeIO -osuf    '_p.o'

make[1]: *** No rule to make target 
`/local/grasp_tmp3/hwloidl/sparc-sun-sunos4/./ghc/lib/../../ghc/includes/error.h',
 needed by `prelude/PreludeIOError_p.hc'.  Stop.
foo%

Solution:

The ghc/lib/Jmake.inc5 in the source distribution contains some links to local Glasgow files. To fix, do `make print_file_lists' and do make again (this will still add some hard-wired paths to the Jmake.inc? files, but at least they're yours now :-)



Empty arrays crashes compacting collector

Symptom:

Programs compiled under either the 1.2 compiler (version 0.xx) or the 1.3 compiler (v. 2.xx) that uses empty arrays (i.e., arrays with bounds (a,b) that define an empty range (a>b)) crash and burn with the (default) generational garbage collector, reporting "Segmentation fault" (or the like). Using the two space collector works fine - what gives?

Solution:

The problem is caused by the marking code in the garbage collector assumed that arrays had to be non-empty - which is not the case for arrays. Fix for 0.29 and 2.01 in their next releases - but if you've got the source installed locally, apply the following patch and recompile the RTS:

*** ghc/runtime/storage/SMmark.lhc      Mon Aug  5 06:14:38 1996
--- ../../../ghc-0.29/ghc/runtime/storage/SMmark.lhc    Tue Jul 23 17:32:21 1996
***************
*** 666,674 ****
          JUMP_MARK_RETURN;
      } else {
!         INIT_MARK_NODE("MUT ", MUTUPLE_CLOSURE_NoPTRS(Mark));
!       if (MUTUPLE_CLOSURE_NoPTRS(Mark) > 0)
!          INIT_MSTACK(MUTUPLE_CLOSURE_PTR);
!       else
!          JUMP_MARK;
      }
      FUNEND;
--- 666,671 ----
          JUMP_MARK_RETURN;
      } else {
!     INIT_MARK_NODE("MUT ", MUTUPLE_CLOSURE_NoPTRS(Mark));
!       INIT_MSTACK(MUTUPLE_CLOSURE_PTR);
      }
      FUNEND;


Building 0.29 hangs at qp2ap

Symptom:

On some platforms, when the STARTUP script gets to ghc/utils/parallel/, it hangs at...

   
   rm -f qp2ap.pl
   echo "#!"/bin/perl > qp2ap.pl
   ../../../glafp-utils/msub/msub  qp2ap.pl >> qp2ap.pl || ( rm -f qp2ap.pl && exit 1 )

Solution:

Drop the spurious first .pl in the qp2ap in the Jmakefile:

*** ghc-0.29/ghc/utils/parallel/Jmakefile.~1~
--- ghc-0.29/ghc/utils/parallel/Jmakefile
***************
*** 40,46 ****
  MsubProgramScriptTarget(PerlCmd,gr2java,gr2java.pl,,)
  MsubProgramScriptTarget(/usr/local/bin/bash,gr2jv,gr2jv.bash,,)
  MsubProgramScriptTarget(/usr/local/bin/bash,gr2ap,gr2ap.bash,,)
! MsubProgramScriptTarget(PerlCmd,qp2ap.pl,qp2ap.pl,,)
  
  MsubProgramScriptTarget(/usr/local/bin/bash,gr2gran,gr2gran.bash,,)
  MsubProgramScriptTarget(PerlCmd,gr2RTS,gr2RTS.pl,,)
--- 40,46 ----
  MsubProgramScriptTarget(PerlCmd,gr2java,gr2java.pl,,)
  MsubProgramScriptTarget(/usr/local/bin/bash,gr2jv,gr2jv.bash,,)
  MsubProgramScriptTarget(/usr/local/bin/bash,gr2ap,gr2ap.bash,,)
! MsubProgramScriptTarget(PerlCmd,qp2ap,qp2ap.pl,,)
  
  MsubProgramScriptTarget(/usr/local/bin/bash,gr2gran,gr2gran.bash,,)
  MsubProgramScriptTarget(PerlCmd,gr2RTS,gr2RTS.pl,,)


>>>>>>> 1.41 <<<<<<< ghc-bugs.html Last modified: Wed Nov 6 00:15:15 1996 Stardate: [-31]8379.28 ======= Last modified: Fri 10 Oct 18:39 BST 1997 by sof@dcs.gla.ac.uk >>>>>>> 1.41