[GHC] #11627: Segmentation fault for space_leak_001 with profiling (-hc)

#11627: Segmentation fault for space_leak_001 with profiling (-hc) -------------------------------------+------------------------------------- Reporter: thomie | Owner: Type: bug | Status: new Priority: high | Milestone: Component: Profiling | Version: 7.10.3 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: perf/space_leaks/space_leak_001 | Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- `WAY=profasm` is omitted by default for this test, but the code looks like this: Test.hs: {{{ import Data.List main = print $ length $ show (foldl' (*) 1 [1..100000] :: Integer) }}} {{{ $ ghc Test.hs -prof -O $ ./Test +RTS -hc Segmentation fault (core dumped) }}} Reproducible with at least 7.10.3 and HEAD, also without `-O`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11627 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11627: Segmentation fault for space_leak_001 with profiling (-hc) -------------------------------------+------------------------------------- Reporter: thomie | Owner: jme Type: bug | Status: new Priority: high | Milestone: Component: Profiling | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | perf/space_leaks/space_leak_001 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by jme): * owner: => jme Comment: The segfault occurs because `shrinkMutableByteArray#` and `resizeMutableByteArray#` introduce slop at the ends of the `large_object` `MutableByteArray#`s holding the `Integer`s. Since the arrays are large, they are not copied during GC, so this slop is still present when the heap census is run (after GC). But when `heapCensusChain` encounters a shrunken `MutableByteArray#`, it thinks the slop following the array is another closure, and chaos quickly ensues. The fix should be straightforward. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11627#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11627: Segmentation fault for space_leak_001 with profiling (-hc) -------------------------------------+------------------------------------- Reporter: thomie | Owner: jme Type: bug | Status: new Priority: high | Milestone: Component: Profiling | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | perf/space_leaks/space_leak_001 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by thomie): Nice find. I do wonder why arrays need to ever be shrunk for this example. The `Integer` only increases in size. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11627#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11627: Segmentation fault for space_leak_001 with profiling (-hc) -------------------------------------+------------------------------------- Reporter: thomie | Owner: jme Type: bug | Status: new Priority: high | Milestone: Component: Profiling | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | perf/space_leaks/space_leak_001 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by jme): Thanks. Although I didn't verify it, I believe the culprit is the `show`, which repeatedly calls `quotRemInteger` to divide the result into smaller chunks. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11627#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11627: Segmentation fault for space_leak_001 with profiling (-hc) -------------------------------------+------------------------------------- Reporter: thomie | Owner: jme Type: bug | Status: new Priority: high | Milestone: Component: Profiling | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | perf/space_leaks/space_leak_001 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by jme): Actually, in `show`, it also possible for the `p*p` in `jsplitf` to trigger a segfault. If `p` is ''w'' words long, 2''w'' words are initially allocated for the result of the multiply. But if the most significant word turns out to be 0, the result is shrunk by a word. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11627#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11627: Segmentation fault for space_leak_001 with profiling (-hc) -------------------------------------+------------------------------------- Reporter: thomie | Owner: jme Type: bug | Status: patch Priority: high | Milestone: Component: Profiling | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | perf/space_leaks/space_leak_001 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2005 Wiki Page: | -------------------------------------+------------------------------------- Changes (by jme): * status: new => patch * differential: => Phab:D2005 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11627#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11627: Segmentation fault for space_leak_001 with profiling (-hc)
-------------------------------------+-------------------------------------
Reporter: thomie | Owner: jme
Type: bug | Status: patch
Priority: high | Milestone:
Component: Profiling | Version: 7.10.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
| perf/space_leaks/space_leak_001
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2005
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11627: Segmentation fault for space_leak_001 with profiling (-hc) -------------------------------------+------------------------------------- Reporter: thomie | Owner: jme Type: bug | Status: merge Priority: high | Milestone: Component: Profiling | Version: 7.10.3 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: | perf/space_leaks/space_leak_001 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2005 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11627#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11627: Segmentation fault for space_leak_001 with profiling (-hc) -------------------------------------+------------------------------------- Reporter: thomie | Owner: jme Type: bug | Status: closed Priority: high | Milestone: 8.0.1 Component: Profiling | Version: 7.10.3 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: Runtime crash | Test Case: | perf/space_leaks/space_leak_001 Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Phab:D2005 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * failure: None/Unknown => Runtime crash * resolution: => fixed * milestone: => 8.0.1 @@ -5,1 +5,1 @@ - {{{ + {{{#!hs New description: `WAY=profasm` is omitted by default for this test, but the code looks like this: Test.hs: {{{#!hs import Data.List main = print $ length $ show (foldl' (*) 1 [1..100000] :: Integer) }}} {{{ $ ghc Test.hs -prof -O $ ./Test +RTS -hc Segmentation fault (core dumped) }}} Reproducible with at least 7.10.3 and HEAD, also without `-O`. -- Comment: Merged as d1fbcbb6710db0e06deac66a77f90d74001acd16. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/11627#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#11627: Segmentation fault for space_leak_001 with profiling (-hc)
-------------------------------------+-------------------------------------
Reporter: thomie | Owner: jme
Type: bug | Status: closed
Priority: high | Milestone: 8.0.1
Component: Profiling | Version: 7.10.3
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Runtime crash | Test Case:
| perf/space_leaks/space_leak_001
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2005
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11627: Segmentation fault for space_leak_001 with profiling (-hc)
-------------------------------------+-------------------------------------
Reporter: thomie | Owner: jme
Type: bug | Status: closed
Priority: high | Milestone: 8.0.1
Component: Profiling | Version: 7.10.3
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Runtime crash | Test Case:
| perf/space_leaks/space_leak_001
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2005
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari

#11627: Segmentation fault for space_leak_001 with profiling (-hc)
-------------------------------------+-------------------------------------
Reporter: thomie | Owner: jme
Type: bug | Status: closed
Priority: high | Milestone: 8.0.1
Component: Profiling | Version: 7.10.3
Resolution: fixed | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Runtime crash | Test Case:
| perf/space_leaks/space_leak_001
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D2005
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari
participants (1)
-
GHC