[GHC] #15508: concprog001 fails with various errors when compiled with -prof

GHC ghc-devs at haskell.org
Thu Aug 23 07:43:32 UTC 2018


#15508: concprog001 fails with various errors when compiled with -prof
-------------------------------------+-------------------------------------
        Reporter:  osa1              |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  high              |            Milestone:  8.6.1
       Component:  Compiler          |              Version:  8.5
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  Runtime crash     |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):  Phab:D5051
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Changes (by osa1):

 * component:  Profiling => Compiler


Old description:

> I'm observing a few different runtime errors. I'm not sure if they're
> because of different bugs so I'm filing one ticket for now.
>
> The reproduce with GHC HEAD:
>
> {{{
> prog001 git:(master) $ ghc-stage2 Mult.hs -prof -fprof-auto -fforce-
> recomp -threaded
> [1 of 7] Compiling Stream           ( Stream.hs, Stream.o )
> [2 of 7] Compiling Converter        ( Converter.hs, Converter.o )
> [3 of 7] Compiling Thread           ( Thread.hs, Thread.o )
> [4 of 7] Compiling Utilities        ( Utilities.hs, Utilities.o )
> [5 of 7] Compiling Trit             ( Trit.hs, Trit.o )
> [6 of 7] Compiling Arithmetic       ( Arithmetic.hs, Arithmetic.o )
> [7 of 7] Compiling Main             ( Mult.hs, Mult.o )
> Linking Mult ...
>
> prog001 git:(master) $ ./Mult +RTS -N2
> Mult: internal error: scavenge_one: strange object 624722688
>     (GHC version 8.7.20180809 for x86_64_unknown_linux)
>     Please report this as a GHC bug:
> http://www.haskell.org/ghc/reportabug
> zsh: abort (core dumped)  ./Mult +RTS -N2
>
> prog001 git:(master) $ ./Mult +RTS -N2
> Mult: internal error: scavenge_stack: weird activation record found on
> stack: 0
>     (GHC version 8.7.20180821 for x86_64_unknown_linux)
>     Please report this as a GHC bug:
> http://www.haskell.org/ghc/reportabug
> zsh: abort (core dumped)  ./Mult +RTS -N2
>
> prog001 git:(master) $ ./Mult +RTS -N2
> zsh: segmentation fault (core dumped)  ./Mult +RTS -N2
> }}}
>
> It's very easy to trigger other kind of panics in `concprog001`, just try
> different compile and runtime flag combinations. Note that for the
> examples below you'll need debug + profiling or debug + profiling +
> threaded runtimes, which are not built by default. To build those apply
> this patch:
>
> {{{
> diff --git a/mk/config.mk.in b/mk/config.mk.in
> index 11050120d4..f083abad22 100644
> --- a/mk/config.mk.in
> +++ b/mk/config.mk.in
> @@ -297,6 +297,7 @@ GhcRTSWays=l
>
>  # Usually want the debug version
>  GhcRTSWays += debug
> +GhcRTSWays += thr_debug_p debug_p
>
>  # We always have the threaded versions, but note that SMP support may be
> disabled
>  # (see GhcWithSMP).
> diff --git a/rts/ghc.mk b/rts/ghc.mk
> index 532c9aa175..ff3f18f30c 100644
> --- a/rts/ghc.mk
> +++ b/rts/ghc.mk
> @@ -329,7 +329,6 @@ WARNING_OPTS += -Wstrict-prototypes
>  WARNING_OPTS += -Wmissing-prototypes
>  WARNING_OPTS += -Wmissing-declarations
>  WARNING_OPTS += -Winline
> -WARNING_OPTS += -Waggregate-return
>  WARNING_OPTS += -Wpointer-arith
>  WARNING_OPTS += -Wmissing-noreturn
>  WARNING_OPTS += -Wnested-externs
> }}}
>
> Examples:
>
> {{{
> prog001 git:(master) $ ghc-stage2 Mult.hs -prof -fprof-auto -fforce-
> recomp -debug
> [1 of 7] Compiling Stream           ( Stream.hs, Stream.o )
> [2 of 7] Compiling Converter        ( Converter.hs, Converter.o )
> [3 of 7] Compiling Thread           ( Thread.hs, Thread.o )
> [4 of 7] Compiling Utilities        ( Utilities.hs, Utilities.o )
> [5 of 7] Compiling Trit             ( Trit.hs, Trit.o )
> [6 of 7] Compiling Arithmetic       ( Arithmetic.hs, Arithmetic.o )
> [7 of 7] Compiling Main             ( Mult.hs, Mult.o )
> Linking Mult ...
>
> prog001 git:(master) $ ./Mult +RTS -DS
> Mult: internal error: ASSERTION FAILED: file rts/sm/Sanity.c, line 210
>
>     (GHC version 8.7.20180809 for x86_64_unknown_linux)
>     Please report this as a GHC bug:
> http://www.haskell.org/ghc/reportabug
> zsh: abort (core dumped)  ./Mult +RTS -DS
> }}}
>
> (I tried to fix this in Phab:D5051 but it's causing a segfault in test
> `T11108` when run with profiling. Not sure what the problem is yet.)
>
> Another way:
>
> {{{
> prog001 git:(master) $ ghc-stage2 Mult.hs -prof -fprof-auto -fforce-
> recomp -threaded
> [1 of 7] Compiling Stream           ( Stream.hs, Stream.o )
> [2 of 7] Compiling Converter        ( Converter.hs, Converter.o )
> [3 of 7] Compiling Thread           ( Thread.hs, Thread.o )
> [4 of 7] Compiling Utilities        ( Utilities.hs, Utilities.o )
> [5 of 7] Compiling Trit             ( Trit.hs, Trit.o )
> [6 of 7] Compiling Arithmetic       ( Arithmetic.hs, Arithmetic.o )
> [7 of 7] Compiling Main             ( Mult.hs, Mult.o )
> Linking Mult ...
>
> prog001 git:(master) $ ./Mult +RTS -N2
> zsh: segmentation fault (core dumped)  ./Mult +RTS -N2
> }}}
>
> Yet another way:
>
> {{{
> prog001 git:(master) $ ghc-stage2 Mult.hs -prof -fprof-auto -fforce-
> recomp -threaded -debug
> [1 of 7] Compiling Stream           ( Stream.hs, Stream.o )
> [2 of 7] Compiling Converter        ( Converter.hs, Converter.o )
> [3 of 7] Compiling Thread           ( Thread.hs, Thread.o )
> [4 of 7] Compiling Utilities        ( Utilities.hs, Utilities.o )
> [5 of 7] Compiling Trit             ( Trit.hs, Trit.o )
> [6 of 7] Compiling Arithmetic       ( Arithmetic.hs, Arithmetic.o )
> [7 of 7] Compiling Main             ( Mult.hs, Mult.o )
> Linking Mult ...
>
> prog001 git:(master) $ ./Mult +RTS -N2
> Mult: internal error: invalid closure, info=0x947edc
>     (GHC version 8.7.20180809 for x86_64_unknown_linux)
>     Please report this as a GHC bug:
> http://www.haskell.org/ghc/reportabug
> zsh: abort (core dumped)  ./Mult +RTS -N2
> }}}
>
> It seems to work fine when not compiled for profiling so marking this bug
> as a profiler bug.

New description:

 I'm observing a few different runtime errors. I'm not sure if they're
 because of different bugs so I'm filing one ticket for now.

 The reproduce with GHC HEAD:

 {{{
 prog001 git:(master) $ ghc-stage2 Mult.hs -prof -fprof-auto -fforce-recomp
 -threaded
 [1 of 7] Compiling Stream           ( Stream.hs, Stream.o )
 [2 of 7] Compiling Converter        ( Converter.hs, Converter.o )
 [3 of 7] Compiling Thread           ( Thread.hs, Thread.o )
 [4 of 7] Compiling Utilities        ( Utilities.hs, Utilities.o )
 [5 of 7] Compiling Trit             ( Trit.hs, Trit.o )
 [6 of 7] Compiling Arithmetic       ( Arithmetic.hs, Arithmetic.o )
 [7 of 7] Compiling Main             ( Mult.hs, Mult.o )
 Linking Mult ...

 prog001 git:(master) $ ./Mult +RTS -N2
 Mult: internal error: scavenge_one: strange object 624722688
     (GHC version 8.7.20180809 for x86_64_unknown_linux)
     Please report this as a GHC bug:
 http://www.haskell.org/ghc/reportabug
 zsh: abort (core dumped)  ./Mult +RTS -N2

 prog001 git:(master) $ ./Mult +RTS -N2
 Mult: internal error: scavenge_stack: weird activation record found on
 stack: 0
     (GHC version 8.7.20180821 for x86_64_unknown_linux)
     Please report this as a GHC bug:
 http://www.haskell.org/ghc/reportabug
 zsh: abort (core dumped)  ./Mult +RTS -N2

 prog001 git:(master) $ ./Mult +RTS -N2
 zsh: segmentation fault (core dumped)  ./Mult +RTS -N2
 }}}

 It's very easy to trigger other kind of panics in `concprog001`, just try
 different compile and runtime flag combinations. Note that for the
 examples below you'll need debug + profiling or debug + profiling +
 threaded runtimes, which are not built by default. To build those apply
 this patch:

 {{{
 diff --git a/mk/config.mk.in b/mk/config.mk.in
 index 11050120d4..f083abad22 100644
 --- a/mk/config.mk.in
 +++ b/mk/config.mk.in
 @@ -297,6 +297,7 @@ GhcRTSWays=l

  # Usually want the debug version
  GhcRTSWays += debug
 +GhcRTSWays += thr_debug_p debug_p

  # We always have the threaded versions, but note that SMP support may be
 disabled
  # (see GhcWithSMP).
 diff --git a/rts/ghc.mk b/rts/ghc.mk
 index 532c9aa175..ff3f18f30c 100644
 --- a/rts/ghc.mk
 +++ b/rts/ghc.mk
 @@ -329,7 +329,6 @@ WARNING_OPTS += -Wstrict-prototypes
  WARNING_OPTS += -Wmissing-prototypes
  WARNING_OPTS += -Wmissing-declarations
  WARNING_OPTS += -Winline
 -WARNING_OPTS += -Waggregate-return
  WARNING_OPTS += -Wpointer-arith
  WARNING_OPTS += -Wmissing-noreturn
  WARNING_OPTS += -Wnested-externs
 }}}

 Examples:

 {{{
 prog001 git:(master) $ ghc-stage2 Mult.hs -prof -fprof-auto -fforce-recomp
 -debug
 [1 of 7] Compiling Stream           ( Stream.hs, Stream.o )
 [2 of 7] Compiling Converter        ( Converter.hs, Converter.o )
 [3 of 7] Compiling Thread           ( Thread.hs, Thread.o )
 [4 of 7] Compiling Utilities        ( Utilities.hs, Utilities.o )
 [5 of 7] Compiling Trit             ( Trit.hs, Trit.o )
 [6 of 7] Compiling Arithmetic       ( Arithmetic.hs, Arithmetic.o )
 [7 of 7] Compiling Main             ( Mult.hs, Mult.o )
 Linking Mult ...

 prog001 git:(master) $ ./Mult +RTS -DS
 Mult: internal error: ASSERTION FAILED: file rts/sm/Sanity.c, line 210

     (GHC version 8.7.20180809 for x86_64_unknown_linux)
     Please report this as a GHC bug:
 http://www.haskell.org/ghc/reportabug
 zsh: abort (core dumped)  ./Mult +RTS -DS
 }}}

 (I tried to fix this in Phab:D5051 but it's causing a segfault in test
 `T11108` when run with profiling. Not sure what the problem is yet.)

 Another way:

 {{{
 prog001 git:(master) $ ghc-stage2 Mult.hs -prof -fprof-auto -fforce-recomp
 -threaded
 [1 of 7] Compiling Stream           ( Stream.hs, Stream.o )
 [2 of 7] Compiling Converter        ( Converter.hs, Converter.o )
 [3 of 7] Compiling Thread           ( Thread.hs, Thread.o )
 [4 of 7] Compiling Utilities        ( Utilities.hs, Utilities.o )
 [5 of 7] Compiling Trit             ( Trit.hs, Trit.o )
 [6 of 7] Compiling Arithmetic       ( Arithmetic.hs, Arithmetic.o )
 [7 of 7] Compiling Main             ( Mult.hs, Mult.o )
 Linking Mult ...

 prog001 git:(master) $ ./Mult +RTS -N2
 zsh: segmentation fault (core dumped)  ./Mult +RTS -N2
 }}}

 Yet another way:

 {{{
 prog001 git:(master) $ ghc-stage2 Mult.hs -prof -fprof-auto -fforce-recomp
 -threaded -debug
 [1 of 7] Compiling Stream           ( Stream.hs, Stream.o )
 [2 of 7] Compiling Converter        ( Converter.hs, Converter.o )
 [3 of 7] Compiling Thread           ( Thread.hs, Thread.o )
 [4 of 7] Compiling Utilities        ( Utilities.hs, Utilities.o )
 [5 of 7] Compiling Trit             ( Trit.hs, Trit.o )
 [6 of 7] Compiling Arithmetic       ( Arithmetic.hs, Arithmetic.o )
 [7 of 7] Compiling Main             ( Mult.hs, Mult.o )
 Linking Mult ...

 prog001 git:(master) $ ./Mult +RTS -N2
 Mult: internal error: invalid closure, info=0x947edc
     (GHC version 8.7.20180809 for x86_64_unknown_linux)
     Please report this as a GHC bug:
 http://www.haskell.org/ghc/reportabug
 zsh: abort (core dumped)  ./Mult +RTS -N2
 }}}

 ~~It seems to work fine when not compiled for profiling so marking this
 bug as a profiler bug.~~

 This program fails sanity checks with non-threaded and non-profiling
 runtime too:

 {{{
 prog001 git:(master) $ ghc-stage2 Mult.hs -fforce-recomp -debug -rtsopts
 [1 of 7] Compiling Stream           ( Stream.hs, Stream.o )
 [2 of 7] Compiling Converter        ( Converter.hs, Converter.o )
 [3 of 7] Compiling Thread           ( Thread.hs, Thread.o )
 [4 of 7] Compiling Utilities        ( Utilities.hs, Utilities.o )
 [5 of 7] Compiling Trit             ( Trit.hs, Trit.o )
 [6 of 7] Compiling Arithmetic       ( Arithmetic.hs, Arithmetic.o )
 [7 of 7] Compiling Main             ( Mult.hs, Mult.o )
 Linking Mult ...

 prog001 git:(master) $ ./Mult +RTS -DS
 Mult: internal error: checkClosure: stack frame
     (GHC version 8.7.20180821 for x86_64_unknown_linux)
     Please report this as a GHC bug:
 http://www.haskell.org/ghc/reportabug
 zsh: abort (core dumped)  ./Mult +RTS -DS
 }}}

--

Comment:

 While messing around with different flags I realized that we don't need
 profiling or threaded flags, it fails some sanity checks in non-threaded
 non-profiled runtime. Updated the description and reverted the component
 from profiler to compiler (not sure if this is a codegen or RTS issue).

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15508#comment:10>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list