[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


Hello,

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-3.0.3.1 to avoid conflict with later version base-4.1.0.0
hiding package network-2.2.1.2 to avoid conflict with later version
network-2.2.1.4
hiding package time-1.1.2.4 to avoid conflict with later version time-1.1.4
wired-in package ghc-prim mapped to ghc-prim-0.1.0.0
wired-in package integer mapped to integer-0.1.0.1
wired-in package base mapped to base-4.1.0.0
wired-in package rts mapped to rts-1.0
wired-in package haskell98 mapped to haskell98-1.0.1.0
wired-in package syb mapped to syb-0.1.0.1
wired-in package template-haskell mapped to template-haskell-2.3.0.1
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)

with

    sc::ServiceCall
    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
difference.

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


Thanks!

Wim


More information about the Haskell-Cafe mailing list