Commit 6252292d authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari

rts/RetainerProfile: Adding missing closure types to isRetainer

orzo in `#ghc` reported seeing a crash due to the retainer profiler encountering
a BLOCKING_QUEUE closure, which isRetainer didn't know about. I performed an
audit to make sure that all of the valid closure types were listed; they
weren't. This is my guess of how they should appear.

Test Plan: Validate

Reviewers: simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #14235

Differential Revision: https://phabricator.haskell.org/D3967
parent 1db0f4a4
/* ---------------------------------------------------------------------------- /* ----------------------------------------------------------------------------
* *
* (c) The GHC Team, 1998-2005 * (c) The GHC Team, 1998-2005
* *
* Closure Type Constants: out here because the native code generator * Closure Type Constants: out here because the native code generator
...@@ -9,11 +9,12 @@ ...@@ -9,11 +9,12 @@
#pragma once #pragma once
/* /*
* WARNING WARNING WARNING * WARNING WARNING WARNING
* *
* If you add or delete any closure types, don't forget to update * If you add or delete any closure types, don't forget to update the following,
* the closure flags table in rts/ClosureFlags.c. * - the closure flags table in rts/ClosureFlags.c
* - isRetainer in rts/RetainerProfile.c
*/ */
/* Object tag 0 raises an internal error */ /* Object tag 0 raises an internal error */
......
...@@ -33,6 +33,18 @@ ...@@ -33,6 +33,18 @@
#include "Stable.h" /* markStableTables */ #include "Stable.h" /* markStableTables */
#include "sm/Storage.h" // for END_OF_STATIC_LIST #include "sm/Storage.h" // for END_OF_STATIC_LIST
/* Note [What is a retainer?]
~~~~~~~~~~~~~~~~~~~~~~~~~~
The definition of what sorts of things are counted as retainers is a bit hard to
pin down. Intuitively, we want to identify closures which will help the user
identify memory leaks due to thunks. In practice we also end up lumping mutable
objects in this group for reasons that have been lost to time.
The definition of retainer is implemented in isRetainer(), defined later in this
file.
*/
/* /*
Note: what to change in order to plug-in a new retainer profiling scheme? Note: what to change in order to plug-in a new retainer profiling scheme?
(1) type retainer in ../includes/StgRetainerProf.h (1) type retainer in ../includes/StgRetainerProf.h
...@@ -1022,6 +1034,9 @@ isRetainer( StgClosure *c ) ...@@ -1022,6 +1034,9 @@ isRetainer( StgClosure *c )
case MUT_VAR_DIRTY: case MUT_VAR_DIRTY:
case MUT_ARR_PTRS_CLEAN: case MUT_ARR_PTRS_CLEAN:
case MUT_ARR_PTRS_DIRTY: case MUT_ARR_PTRS_DIRTY:
case SMALL_MUT_ARR_PTRS_CLEAN:
case SMALL_MUT_ARR_PTRS_DIRTY:
case BLOCKING_QUEUE:
// thunks are retainers. // thunks are retainers.
case THUNK: case THUNK:
...@@ -1069,17 +1084,21 @@ isRetainer( StgClosure *c ) ...@@ -1069,17 +1084,21 @@ isRetainer( StgClosure *c )
// closures. See trac #3956 for a program that hit this error. // closures. See trac #3956 for a program that hit this error.
case IND_STATIC: case IND_STATIC:
case BLACKHOLE: case BLACKHOLE:
case WHITEHOLE:
// static objects // static objects
case FUN_STATIC: case FUN_STATIC:
// misc // misc
case PRIM: case PRIM:
case BCO: case BCO:
case ARR_WORDS: case ARR_WORDS:
case COMPACT_NFDATA:
// STM // STM
case TREC_CHUNK: case TREC_CHUNK:
// immutable arrays // immutable arrays
case MUT_ARR_PTRS_FROZEN: case MUT_ARR_PTRS_FROZEN:
case MUT_ARR_PTRS_FROZEN0: case MUT_ARR_PTRS_FROZEN0:
case SMALL_MUT_ARR_PTRS_FROZEN:
case SMALL_MUT_ARR_PTRS_FROZEN0:
return false; return false;
// //
...@@ -1089,11 +1108,15 @@ isRetainer( StgClosure *c ) ...@@ -1089,11 +1108,15 @@ isRetainer( StgClosure *c )
// legal objects during retainer profiling. // legal objects during retainer profiling.
case UPDATE_FRAME: case UPDATE_FRAME:
case CATCH_FRAME: case CATCH_FRAME:
case CATCH_RETRY_FRAME:
case CATCH_STM_FRAME:
case UNDERFLOW_FRAME: case UNDERFLOW_FRAME:
case ATOMICALLY_FRAME:
case STOP_FRAME: case STOP_FRAME:
case RET_BCO: case RET_BCO:
case RET_SMALL: case RET_SMALL:
case RET_BIG: case RET_BIG:
case RET_FUN:
// other cases // other cases
case IND: case IND:
case INVALID_OBJECT: case INVALID_OBJECT:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment