[GHC] #14758: Retainer profiler can overflow the C stack

#14758: Retainer profiler can overflow the C stack
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: (none)
Type: bug | Status: new
Priority: high | Milestone:
Component: Profiling | Version: 8.4.1-alpha1
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: None/Unknown
Unknown/Multiple |
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
I'm not entirely sure what conditions trigger this, but I am observing a
reliable segmentation fault with a program with large heap compiled with
8.4.1-alpha3 and run with retainer profiling enabled. Judging by the fact
that the crashing instruction is a `mov _, ($rsp)`, I'm reasonable certain
that the issue is a C stack overflow. The top of the stack looks like,
{{{
#0 0x000000000249212c in retainClosure (c0=0x42af3459b8,
cp0=cp0@entry=0x42af347000, r0=r0@entry=0x42bc4fd1a0) at
rts/RetainerProfile.c:1488
#1 0x00000000024932b0 in retain_small_bitmap (c_child_r=0x42bc4fd1a0,
c=0x42af347000, bitmap=<optimized out>, size=<optimized out>,
p=0x42af347260) at rts/RetainerProfile.c:1209
#2 retainStack (c=c@entry=0x42af347000,
c_child_r=c_child_r@entry=0x42bc4fd1a0, stackStart=<optimized out>,
stackEnd=0x42af347370) at rts/RetainerProfile.c:1350
#3 0x0000000002492870 in retainClosure (c0=<optimized out>,
cp0=cp0@entry=0x42af345b28, r0=r0@entry=0x2a5ac20

#14758: Retainer profiler can overflow the C stack -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: high | Milestone: Component: Profiling | Version: 8.4.1-alpha1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15287 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * related: => #15287 Comment: I suspect that #15287 is another manifestation of this. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14758#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14758: Retainer profiler can overflow the C stack -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Profiling | Version: 8.6.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15287 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * priority: high => normal * keywords: => newcomer * version: 8.4.1-alpha1 => 8.6.1 Comment: Just a status update: we discussed this a few weeks ago in a meeting. This is easy to fix, just replace recursive calls to `retainClosure` (directly or indirectly via `retainStack`) with stack pushes. For this we need to add new stack element types handle those in `retainClosure` (which is where we pop the stack). Not too hard to do. In the end we weren't sure that retainer profiler is too useful in practice, so we did not prioritize this (I'm updating the ticket priority now to reflect this). If you're using retainer profiler for anything useful and suffering from this bug, let us know. Also, this seems like a great newcomer ticket to me. The changes are only in one file (`RetainerProfile.c`) and you only need to know GHC heap object layout and some C. If anyone's interested in working on this let me know and I can give more detailed instructions. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14758#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14758: Retainer profiler can overflow the C stack -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Profiling | Version: 8.6.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15287 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * cc: osa1 (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14758#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14758: Retainer profiler can overflow the C stack -------------------------------------+------------------------------------- Reporter: bgamari | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Profiling | Version: 8.6.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15287 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by maoe): * cc: maoe (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14758#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14758: Retainer profiler can overflow the C stack -------------------------------------+------------------------------------- Reporter: bgamari | Owner: qnikst Type: bug | Status: new Priority: normal | Milestone: Component: Profiling | Version: 8.6.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15287 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by qnikst): * owner: (none) => qnikst Comment: I'm going to work on this ticket during Munihac. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14758#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14758: Retainer profiler can overflow the C stack -------------------------------------+------------------------------------- Reporter: bgamari | Owner: qnikst Type: bug | Status: patch Priority: normal | Milestone: Component: Profiling | Version: 8.6.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15287 | Differential Rev(s): Phab:D5351 Wiki Page: | -------------------------------------+------------------------------------- Changes (by qnikst): * status: new => patch * differential: => Phab:D5351 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14758#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14758: Retainer profiler can overflow the C stack -------------------------------------+------------------------------------- Reporter: bgamari | Owner: qnikst Type: bug | Status: patch Priority: normal | Milestone: 8.6.3 Component: Profiling | Version: 8.6.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15287 | Differential Rev(s): Phab:D5351 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * milestone: => 8.6.3 Comment: Let's try to get this in to 8.6.3. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14758#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14758: Retainer profiler can overflow the C stack
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: qnikst
Type: bug | Status: patch
Priority: normal | Milestone: 8.6.3
Component: Profiling | Version: 8.6.1
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #15287 | Differential Rev(s): Phab:D5351
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ömer Sinan Ağacan

#14758: Retainer profiler can overflow the C stack -------------------------------------+------------------------------------- Reporter: bgamari | Owner: qnikst Type: bug | Status: merge Priority: normal | Milestone: 8.6.3 Component: Profiling | Version: 8.6.1 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15287 | Differential Rev(s): Phab:D5351 Wiki Page: | -------------------------------------+------------------------------------- Changes (by osa1): * status: patch => merge -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14758#comment:9 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14758: Retainer profiler can overflow the C stack -------------------------------------+------------------------------------- Reporter: bgamari | Owner: qnikst Type: bug | Status: closed Priority: normal | Milestone: 8.6.3 Component: Profiling | Version: 8.6.1 Resolution: fixed | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: #15287 | Differential Rev(s): Phab:D5351 Wiki Page: | -------------------------------------+------------------------------------- Changes (by bgamari): * status: merge => closed * resolution: => fixed -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14758#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#14758: Retainer profiler can overflow the C stack
-------------------------------------+-------------------------------------
Reporter: bgamari | Owner: qnikst
Type: bug | Status: closed
Priority: normal | Milestone: 8.6.3
Component: Profiling | Version: 8.6.1
Resolution: fixed | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #15287 | Differential Rev(s): Phab:D5351
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari
participants (1)
-
GHC