Ticket #4034 (closed bug: fixed)

Opened 3 years ago

Last modified 2 years ago

GHC > 6.10 fails to build on PowerPC / MacOS X Leopard

Reported by: PHO Owned by:
Priority: low Milestone: 7.0.1
Component: Compiler Version: 7.1
Keywords: Cc:
Operating System: MacOS X Architecture: powerpc
Type of failure: GHCi crash Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

I'm trying to build GHC 6.12.2 on PowerPC / MacOS 10.5.8, but stage2 compiler causes an internal error:

"inplace/bin/ghc-stage2" -H32m -O -DNEW_GHC_LAYOUT
-hide-all-packages -i -iutils/haddock/src
-iutils/haddock/dist/build -iutils/haddock/dist/build/autogen
-Iutils/haddock/dist/build -Iutils/haddock/dist/build/autogen
-optP-DIN_GHC_TREE -optP-include
-optPutils/haddock/dist/build/autogen/cabal_macros.h -package
Cabal-1.8.0.4 -package array-0.3.0.0 -package base-4.2.0.1
-package containers-0.3.0.0 -package directory-1.0.1.1 -package
filepath-1.1.0.4 -package ghc-6.12.2 -package pretty-1.0.1.1
-funbox-strict-fields -O2 -Wall -XForeignFunctionInterface -XCPP
-XPatternGuards -XDeriveDataTypeable -XScopedTypeVariables
-XMagicHash -odir utils/haddock/dist/build -hidir
utils/haddock/dist/build -stubdir utils/haddock/dist/build -hisuf
hi -osuf o -hcsuf hc -c
utils/haddock/src/Haddock/InterfaceFile.hs -o
utils/haddock/dist/build/Haddock/InterfaceFile.o
ghc-stage2: internal error: evacuate: strange closure type 24576
    (GHC version 6.12.2 for powerpc_apple_darwin)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

The stage2 compiler is built with -thread by default, so I tried building it with -debug. As a result, the compiler caused Segmentation Fault on the same source file. The SegFault? happened at some internal function like "s1ht_info" in "compiler/stage2/build/UniqFM.o".

Change History

Changed 3 years ago by PHO

  • summary changed from GHC 6.12.2 crashes on PowerPC / MacOS X Leopard to GHC 6.12.2 fails to build on PowerPC / MacOS X Leopard

Changed 3 years ago by PHO

Here is the assembly code that caused a SegFault?:

0x012a42c4 <s1ht_info+0>:       lis     r31,298
0x012a42c8 <s1ht_info+4>:       addi    r31,r31,16880
0x012a42cc <s1ht_info+8>:       stw     r31,0(r22)
0x012a42d0 <s1ht_info+12>:      andi.   r31,r14,3
0x012a42d4 <s1ht_info+16>:      cmpwi   r31,0
0x012a42d8 <s1ht_info+20>:      bne-    0x12a42e8 <s1ht_info+36>
0x012a42dc <s1ht_info+24>:      lwz     r31,0(r14) ; CRASHES HERE
0x012a42e0 <s1ht_info+28>:      mtctr   r31
0x012a42e4 <s1ht_info+32>:      bctr
0x012a42e8 <s1ht_info+36>:      b       0x12a41f0 <s1wl_info>
0x012a42ec <s1ht_info+40>:      .long 0xc

SegFault? occurs at s1ht_info+24 trying to load a word pointed by r14 (STG R1 register) but the value of r14 is zero.

The corresponding C-- code is:

s1ht_ret()
        { has static closure: False update_frame: <none>
          type: 0
          desc: 0
          tag: 34
          stack: [Nothing]
          srt: (ghczm6zi12zi2_UniqFM_lookUp_srt,0,1)
        }
    c1Mq:
        I32[Sp + 0] = s1wl_info;
        if (R1 & 3 != 0) goto c1Mt;
        jump I32[R1] (); /* CRASHES HERE */
    c1Mt: jump s1wl_info ();
}

Changed 3 years ago by PHO

I found I can avoid the problem by putting the following options to mk/build.mk:

GhcRtsHcOpts = -optc-O0 -optc-g
GhcRtsCcOpts = -O0 -g

This is my observation so far:

  • Optimized libHSrts_thr.a causes an evacuate() error.
  • libHSrts_debug.a causes a segmentation fault.
  • Unoptimized libHSrts_thr.a looks working.

...so the problem is not likely in gcc's optimizer but in rts. GCC is just revealing the hidden rts bug.

Changed 3 years ago by simonmar

  • milestone set to 6.12.3

You can narrow down the problem by compiling individual modules in the RTS with or without -optc-O2. Also try the sanity checker (+RTS -DS). It will make things easier if you find a smaller program from the testsuite that fails, rather than GHC itself.

I'd like to point out that it's not unknown for GCC to have bugs - we've had to work around them in the past, e.g. look in LdvProfile.c.

Changed 3 years ago by PHO

Thank you for your suggestion. In fact, I tried +RTS -DS before posting this report but that didn't make any differences. (-DS needs -debug rts and it behaves just like the normal -debug rts; the SEGV.)

Btw, I found the problem didn't occur at all on the current darcs HEAD. I'll try to find the testsuite that fails when I stumble on it again.

Changed 3 years ago by igloo

  • priority changed from normal to low
  • milestone changed from 6.12.3 to 6.14.1

Changed 3 years ago by igloo

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

Closing, as it doesn't happen in the HEAD.

Changed 3 years ago by maeder

  • status changed from closed to new
  • resolution fixed deleted

my attempt to build ghc-7.0.0.20100924 on powerpc (leopard) failed with:

"inplace/bin/ghc-stage1" -M -dep-makefile utils/compare_sizes/dist/build/.depend.haskell.tmp  -include-pkg-deps -H32m -O -hide-all-packages -i -iutils/compare_sizes/. -iutils/compare_sizes/dist/build -iutils/compare_sizes/dist/build/autogen -Iutils/compare_sizes/dist/build -Iutils/compare_sizes/dist/build/autogen -optP-include -optPutils/compare_sizes/dist/build/autogen/cabal_macros.h -package base-4.3.0.0 -package directory-1.1.0.0 -package filepath-1.2.0.0 -no-user-package-conf -rtsopts -odir utils/compare_sizes/dist/build -hidir utils/compare_sizes/dist/build -stubdir utils/compare_sizes/dist/build -hisuf hi -osuf o -hcsuf hc  utils/compare_sizes/./Main.hs
ghc-stage1: internal error: evacuate(static): strange closure type 19216
    (GHC version 6.10.4 for powerpc_apple_darwin)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug
make[1]: *** [utils/compare_sizes/dist/build/.depend.haskell] Abort trap
make: *** [all] Error 2

Changed 3 years ago by maeder

  • version changed from 6.12.2 to 7.1
  • summary changed from GHC 6.12.2 fails to build on PowerPC / MacOS X Leopard to GHC > 6.10 fails to build on PowerPC / MacOS X Leopard

Was someone else able to create a newer ghc for ppc? It seems the bootstrapping compiler (ghc-6.10) fails to compile ghc-7.

Changed 3 years ago by PHO

I can build the darcs HEAD on ppc with the patch I posted to #1845. The compiler I'm currently using is GHC 6.12.3.

Changed 3 years ago by maeder

So someone should create a binary ghc-6.12.3 distribution for ppc first and put it on  http://darcs.haskell.org/download/download_ghc_6_12_3.html#binaries

Changed 3 years ago by PHO

I built a bindist but this is not for general use as GHCi is totally broken. ghc --make still works so you should be able to use this to bootstrap the HEAD.

 http://static.cielonegro.org/archive/ghc-6.12.3-powerpc-apple-darwin.tar.bz2

Changed 3 years ago by maeder

Ok, I'll try it out. Can you tell me how to apply your patch to the non-darcs sources of ghc-6.12.3?

Changed 3 years ago by maeder

I cannot use your binary distribution, because it depends on the framework GMP, that I don't have.

checking for path to top of build tree... ld: framework not found GMP

ghc-pkg describe integer-gmp shows:

frameworks: GMP

Changed 3 years ago by maeder

removing this frameworks entry and calling ghc-pkg recache resolves this.

Changed 3 years ago by maeder

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

I could create a binary dist for ghc-7 RC1 (that will hopefully do to bootstrap the final ghc-7):  http://www.informatik.uni-bremen.de/agbkb/forschung/formal_methods/CoFI/hets/mac/ghcs/ghc-7.0.0.20100924-powerpc-apple-darwin.tar.bz2

Changed 3 years ago by igloo

I've put the two bindists at  http://new-www.haskell.org/ghc/dist/tmp/ for now.

Changed 2 years ago by PHO

  • failure changed from Building GHC failed to GHCi crash

I just built 7.0.1 with GhcDebugged?=YES. The building process succeeded, but when I run "./inplace/bin/ghc-stage2 --interactive", the following error occurs:

Running

./inplace/bin/ghc-stage2 --interactive +RTS -DS

...in GDB:

GHCi, version 7.0.1: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
ghc-stage2: internal error: ASSERTION FAILED: file rts/sm/Sanity.c, line 87

    (GHC version 7.0.1 for powerpc_apple_darwin)
    Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

Program received signal SIGABRT, Aborted.
0x97041b50 in __kill ()
(gdb) bt
#0  0x97041b50 in __kill ()
#1  0x970dcc00 in abort ()
#2  0x01f2b074 in rtsFatalInternalErrorFn (s=0x20aa134 "ASSERTION FAILED: file %
s, line %u\n", ap=0xbfffe22c "\002\n��") at rts/RtsMessages.c:170
#3  0x01f2ac60 in barf (s=0x20aa134 "ASSERTION FAILED: file %s, line %u\n") at rts/RtsMessages.c:42
#4  0x01f2acdc in _assertFail (filename=0x20aded0 "rts/sm/Sanity.c", linenum=87) at rts/RtsMessages.c:57
#5  0x01f4f2b4 in checkClosureShallow (p=0xb5ebdff0) at rts/sm/Sanity.c:87
#6  0x01f4f12c in checkSmallBitmap (payload=0x3c76e64, bitmap=126, size=8) at rts/sm/Sanity.c:52
#7  0x01f4f614 in checkStackFrame (c=0x3c76e58) at rts/sm/Sanity.c:118
#8  0x01f4f960 in checkStackChunk (sp=0x3c76e58, stack_end=0x3c77000) at rts/sm/Sanity.c:202
#9  0x01f50c44 in checkTSO (tso=0x3c76000) at rts/sm/Sanity.c:546
#10 0x01f33414 in scheduleHandleYield (cap=0x21f8ac0, t=0x3c76000, prev_what_next=1) at rts/Schedule.c:1152
#11 0x01f31aa4 in schedule (initialCapability=0x21f8ac0, task=0xb0089f40) at rts/Schedule.c:519
#12 0x01f349c0 in scheduleWaitThread (tso=0x3c80944, ret=0x0, cap=0x21f8ac0) at rts/Schedule.c:1902
#13 0x01f278e8 in rts_evalLazyIO (cap=0x21f8ac0, p=0x20b1ca0, ret=0x0) at rts/RtsAPI.c:495
#14 0x01f2aa58 in real_main () at rts/RtsMain.c:66
#15 0x01f2abe4 in hs_main (argc=13, argv=0xbfffe718, main_init=0x16be8 <__stginit_ZCMain>, main_closure=0x20b1ca0) at rts/RtsMain.c:115
#16 0x00001f24 in start ()
(gdb) 

Running GHCi without GhcDebugged?=YES also fails with "evacuate: strange closure type" error. I haven't tried the current darcs HEAD yet.

Changed 2 years ago by igloo

Thanks; I've added it to the download page.

Note: See TracTickets for help on using tickets.