[Haskell-cafe] segmentation fault with ghc-6.10.4 on linux-x86_x64

Wim Vanderbauwhede wim.vanderbauwhede at gmail.com
Tue Mar 2 05:29:15 EST 2010


I'm writing a compiler and it segfaults when compiled with  ghc-6.10.4
on linux-x86_x64.
It runs fine when compiled with ghc-6.10.4 on Mac OS X 10.5 (64-bit
Intel) and with ghc-6.8.2 on Mac OS X 10.4 (32-bit PPC).
I use the Haskell platform, the ghc -v output is

Glasgow Haskell Compiler, Version 6.10.4, for Haskell 98, stage 2
booted by GHC version 6.8.2
Using package config file: /usr/local/lib/ghc-6.10.4/./package.conf
Using package config file: /users/wim/.ghc/x86_64-linux-6.10.4/package.conf
hiding package base- to avoid conflict with later version base-
hiding package network- to avoid conflict with later version
hiding package time- to avoid conflict with later version time-1.1.4
wired-in package ghc-prim mapped to ghc-prim-
wired-in package integer mapped to integer-
wired-in package base mapped to base-
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-
wired-in package syb mapped to syb-
wired-in package template-haskell mapped to template-haskell-
wired-in package dph-seq mapped to dph-seq-0.3
wired-in package dph-par mapped to dph-par-0.3

The offending code is (simplified)

    mapM emit (sc_args sc)


    data ServiceCall = MkServiceCall { sc_args::[Expr], ... }
    data Expr = PureE (PString String) | ...

and emit defined via a type class EmitG:

    emitExpr (PureE e) = emit e
   instance EmitG Expr where emit = emitExpr

    emitPureExpr (PString s) = return $ show s
    instance EmitG PureExpr where emit = emitPureExpr

So it actually maps "show" over a list of strings.

The compiler parses a test program, the segfault occurs when emitting
code for lines like
  ImgBlock() img1 = img.in("img.raw");
(a "service call" in my language)
Replacing the string by a number of any other type of the AST makes no

It looks like a bug in ghc's memory allocation. Any suggestions on how
to debug this?



More information about the Haskell-Cafe mailing list