[GHC] #12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48

#12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48 -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Runtime crash Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Found this working on #11978. {{{ $ cat hello.hs main :: IO () main = putStrLn "Hello" $ ghc -fforce-recomp -prof -threaded -debug --make hello.hs -o hello [1 of 1] Compiling Main ( hello-world.hs, hello-world.o ) Linking hello ... $ ./hello +RTS -hb -DS -N1 7f68030c1700: cap 0: initialised Hello 7f68030c1700: cap 0: shutting down hello-world: internal error: ASSERTION FAILED: file rts/LdvProfile.c, line 48 (GHC version 7.10.3 for x86_64_unknown_linux) Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug Aborted }}} Also tried this with git HEAD and get the same result. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12009 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48 -------------------------------------+------------------------------------- Reporter: erikd | Owner: Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Adding a `printf` before the `ASSERT`: {{{#!C printf ("%s %d : era %u %lu\n", __func__, __LINE__, era, (LDVW(c) & LDV_CREATE_MASK) >> LDV_SHIFT) ; }}} results in: {{{ 7fca8b085700: cap 0: shutting down processHeapClosureForDead 47 : era 1 1 processHeapClosureForDead 47 : era 1 1 . . . processHeapClosureForDead 47 : era 1 1 processHeapClosureForDead 47 : era 1 1 processHeapClosureForDead 47 : era 1 715827882 hello: internal error: ASSERTION FAILED: file rts/LdvProfile.c, line 50 }}} The value `715827882` in hex is `0x2aaaaaaa`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12009#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48 -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by erikd): * owner: => erikd -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12009#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48 -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): The test I have for #11978 triggers this `ASSERT` as well. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12009#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48 -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Wow, this is interesting. Note that I am running the test program with `+RTS -hb -DS -N1` and its crashing in `processNurseryForDead` which has some code that looks like: {{{ p = bd->start; while (p < bd->free) { while (p < bd->free && !*p) p++; // skip slop if (p >= bd->free) break; }}} The line with the `skip slop` comment is the interesting one. It assumes that if the block descriptor we are currently looking at is not full, then the memory from `bd->start` to `bd-free` with be all zeros. However, this is not the case when the RTS flags include `-DS` which turns on sanity checking. One part of this sanity checking is in the function `resetNurseries` of the file `rts/sm/Storage.c` which does this: {{{ IF_DEBUG(sanity, memset(bd->start, 0xaa, BLOCK_SIZE)); }}} That is, it fills the block with `0xaa` bytes which causes the "skip slop" code in `processNurseryForDead` to incorrectly skip the slop at the start of the block. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12009#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48 -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): The following patch prevents the crash, but may result in in-correct heap profiling results: {{{#!diff diff --git a/rts/LdvProfile.c b/rts/LdvProfile.c index 1dfdc56..43a47aa 100644 --- a/rts/LdvProfile.c +++ b/rts/LdvProfile.c @@ -184,7 +184,14 @@ processNurseryForDead( void ) for (bd = MainCapability.r.rNursery->blocks; bd != NULL; bd = bd->link) { p = bd->start; while (p < bd->free) { + // The start of the block may be zero filled which we need to skip + // over. while (p < bd->free && !*p) p++; // skip slop + + // In debug mode, with sanity checking enabled, start of the block + // may be filled with `0xaa` so if we find it, we just break. + IF_DEBUG(sanity, if (*((StgWord32*)p) == 0xaaaaaaaa) break;); + if (p >= bd->free) break; p += processHeapClosureForDead((StgClosure *)p); } }}} Maybe we could print a warning about inaccuracey if debug sanity checking is on in profiling mode. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12009#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48 -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): The fix is insufficient. I am still getting intermittent assertion failures on {{{#!C ASSERT(((LDVW(c) & LDV_CREATE_MASK) >> LDV_SHIFT) > 0); }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12009#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48 -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by erikd): * cc: carter (added) Comment: Oh wow, just realised that the profiling code is not thread safe!!!!! The function `LDV_recordDead` mutates global variable `censuses` which does not have any locking around it. Only figured this out because the following assert (in `LDV_recordDead`) was being triggered. {{{ ASSERT(censuses[t].void_total < censuses[t].not_used); }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12009#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48 -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: new Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by erikd): Wow, that assert is even triggered when the test program is run as `./T11978b +RTS -hb -N1`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12009#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#12009: ASSERTION FAILED: file rts/LdvProfile.c, line 48 -------------------------------------+------------------------------------- Reporter: erikd | Owner: erikd Type: bug | Status: closed Priority: normal | Milestone: 8.0.2 Component: Compiler | Version: 7.10.3 Resolution: duplicate | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by erikd): * status: new => closed * resolution: => duplicate Comment: This bug is actually caused by the fact that the `-hb` profiling mode is not thread safe. Closing this in favour of #12019 which gives a much better explanation. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12009#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC