Ticket #5810 (closed bug: fixed)

Opened 16 months ago

Last modified 13 months ago

OSX Lion building 7.4 head causes Haddock Divide By Zero

Reported by: codeweaver Owned by:
Priority: highest Milestone: 7.4.2
Component: Compiler Version: 7.4.1-rc1
Keywords: haddock divide by zero internal error Cc: pho@…, ireney.knapp@…
Operating System: MacOS X Architecture: Other
Type of failure: Building GHC failed Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description (last modified by igloo) (diff)

After installing 7.2.2 64 bit onto a GHC-free system, I tried to build the full 7.4 head from git repositories according to the wiki instructions. The result was:

haddock: internal error: divide by zero
make[1]: *** [libraries/base/dist-install/doc/html/base/base.haddock] Error 1
make: *** [all] Error 2

This halted the build.

More detail follows -- a little bit more output, followed by reproduction steps.

Haddock coverage:
  50% (  1 /  2) in 'Unsafe.Coerce'
   0% (  0 /  1) in 'GHC.IO.Encoding.CodePage'
Warning: base:GHC.Base: Could not find documentation for exported module: GHC.Err
  65% ( 30 / 46) in 'GHC.Base'
  67% (  4 /  6) in 'GHC.Num'
 100% (  6 /  6) in 'Data.Tuple'
 100% ( 11 / 11) in 'Data.Maybe'
  89% ( 42 / 47) in 'GHC.List'
  65% ( 11 / 17) in 'GHC.Show'
  33% (  3 /  9) in 'GHC.Enum'
  25% (  2 /  8) in 'Text.Show'
  95% ( 41 / 43) in 'Control.Monad'
  50% (  5 / 10) in 'GHC.ST'
  34% ( 17 / 50) in 'GHC.Arr'
 100% (  6 /  6) in 'GHC.Exception'
  50% (  3 /  6) in 'GHC.Err'
  50% ( 16 / 32) in 'GHC.Real'
  59% ( 19 / 32) in 'GHC.IO'
  88% (  7 /  8) in 'GHC.IOArray'
 100% (  3 /  3) in 'Foreign.Marshal.Unsafe'
 100% ( 11 / 11) in 'GHC.MVar'
 100% (  2 /  2) in 'Data.Bits'
  29% (  9 / 31) in 'GHC.Float.RealFracMethods'
  33% (  1 /  3) in 'GHC.Float.ConversionUtils'
haddock: internal error: divide by zero
make[1]: *** [libraries/base/dist-install/doc/html/base/base.haddock] Error 1
make: *** [all] Error 2

Reproduction Steps:


Xcode 4.2.1 Build version 4D502

Mac OSX Lion 10.7.2 (11C74) (from About This Mac)

hardware:

Model Name:	MacBook Pro
  Model Identifier:	MacBookPro8,2
  Processor Name:	Intel Core i7
  Processor Speed:	2.3 GHz
  Number of Processors:	1
  Total Number of Cores:	4
  L2 Cache (per Core):	256 KB
  L3 Cache:	8 MB
  Memory:	8 GB
  Boot ROM Version:	MBP81.0047.B24
  SMC Version (system):	1.69f3

Step 1:

Install on a clean system the installer based package from

http://www.haskell.org/ghc/download_ghc_7_2_2#macosx_x86_64

Step 2: Acquiring the 7.4 source:

(according to  http://hackage.haskell.org/trac/ghc/wiki/Building/GettingTheSources)

mkdir ghc-builds
cd ghc-builds
git clone -b ghc-7.4 http://darcs.haskell.org/ghc.git/ ghc-7.4
cd ghc-7.4
./sync-all --testsuite get -b ghc-7.4
./sync-all pull

Step 3: Backed up ghc-7.4 to archive .rar file for wipe-and-rebuild

Step 4: Configuration and make

(according to  http://hackage.haskell.org/trac/ghc/wiki/Building/Hacking)

perl boot
./configure --prefix=/Users/michaeljones/ghc-builds/ghc-7.4-install
make

Change History

follow-up: ↓ 2   Changed 16 months ago by codeweaver

  • os changed from Unknown/Multiple to MacOS X
  • architecture changed from x86_64 (amd64) to Other

in reply to: ↑ 1   Changed 16 months ago by codeweaver

Replying to codeweaver:

It appears to be happening during the inplace/bin/ghc-stage1 profile build of stage 2 (or immediately after it), as observed by the -prof switches in all the executions of ghc-stage1 shortly before this.

Specifically it is during the execution of haddock that begins thusly:

"/Users/michaeljones/ghc-builds/ghc-7.4/inplace/bin/haddock" --odir="libraries/base/dist-install/doc/html/base" --no-tmp-comp-dir --dump-interface=libraries/base/dist-install/doc/html/base/base.haddock --html --hoogle --title="base-4.5.0.0: Basic libraries" --prologue="libraries/base/dist-install/haddock-prologue.txt" --hide=GHC.Event.Array --hide=GHC.Event.Clock --hide=GHC.Event.Control --hide=GHC.Event.EPoll

  Changed 16 months ago by codeweaver

  • version changed from 7.2.2 to 7.4.1-rc1

My apologies. I'm a bit new at this. Apparently I'm supposed to mark this bug as being for 7.4 as the target rather than 7.2.2 as the starting platform. So I'm making that change here.

  Changed 16 months ago by edsko

I got the same problem (ghc-7.4.0.20120119). Worked around it by disabling haddock in build.mk. After that it installed, but then when I tried to build cabal-install *that* failed with a divide by zero error. After some tracking down, turns out things seem to be very broken:

# ghci GHCi, version 7.4.0.20120119: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> 1.05 *** Exception: divide by zero Prelude> 1.04 (hangs completely)

  Changed 16 months ago by PHO

  • cc pho@… added

  Changed 16 months ago by igloo

  • difficulty set to Unknown
  • description modified (diff)

  Changed 16 months ago by igloo

  • description modified (diff)

  Changed 16 months ago by igloo

  • priority changed from normal to highest
  • milestone set to 7.4.1

I can reproduce this if I make the build use /usr/bin/gcc (the LLVM gcc), but not using /usr/bin/gcc-4.2.

I'll make it highest priority, but I don't think we want to hold the release up if we don't have a fix in time.

  Changed 16 months ago by Irene

This is a duplicate of a bug I reported and spent considerable effort diagnosing around October, but it was closed at that time as "cannot reproduce" although I don't think anyone followed the directions I gave properly. I believe the long time before somebody else reported it means that, as I surmised, I was simply the only one attempting to build GHC on OS X Lion and that it has been broken all this time. I can't find that bug in the system now, possibly due to my user-name change or something of that sort, so I'll summarize here.

There are two underlying problems. The more serious one is that cross-module inlining is only occurring when profiling is on, due to a change in where the function definitions are stored in the .hi files; as a result, rules that perform constant folding on arithmetic primops are not happening, so that a rational number is being constructed at runtime instead of compile-time. The immediate cause of the divide-by-zero is that we are using a GMP function in an undocumented way (and always have been), so that it returns zero. Even if one chooses to regard this as GMP's bug in an abstract philosophical sense ("the documentation ought to be clearer", perhaps), we're probably the only people hit by it, and it's breaking our build completely on OS X, so we kind of have to deal with it.

I'll try again to dig up the original bug report when I get home from work tonight; it went into much more detail.

  Changed 16 months ago by chak

I did run into this as well a while back, but it disappeared again (after pulling some more commits or so). I am pretty sure that I used /usr/bin/gcc-4.2, though.

  Changed 16 months ago by Irene

  • cc ireney.knapp@… added

#5663 is the old report.

  Changed 16 months ago by simonmar

I can't repeat the problem from #5663 on: x86_64/Linux with today's HEAD, or OS X 10.6.8 with a 7.5 built a few weeks ago.

Ian, I think you'll need to dig into it in your build that reproduced the error.

  Changed 16 months ago by igloo

  • owner set to igloo

  Changed 16 months ago by igloo

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

I think this is fixed by:

commit 552504663774d4ad2528d466f08841b5b78c7518

Author: Ian Lynagh <igloo@earth.li>
Date:   Fri Feb 3 17:03:21 2012 +0000

    Updated to a newer version of gmp; fixes #5810

    I didn't diagnose the problem, but with the newer GMP the problem seems
    fixed. There are a couple of things that look like candidates for the
    bug:
    * A few minor bugs related to portability fixed.
    * A bug in division code possibly causing incorrect computation was fixed.

Please let us know if you still have problems.

  Changed 14 months ago by luite

I'm still seeing this problem with the GHC 7.4.1.20120406 STABLE snapshot. Has this been fixed only in HEAD?

  Changed 14 months ago by simonmar

  • owner igloo deleted
  • status changed from closed to new
  • resolution fixed deleted

  Changed 14 months ago by simonmar

  • milestone changed from 7.4.1 to 7.4.2

  Changed 13 months ago by pcapriotti

  • status changed from new to merge

  Changed 13 months ago by pcapriotti

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

Merged as 9febee4d65728d1613cd5c54e80100c09d65b9b9.

Note: See TracTickets for help on using tickets.