Note [No static object resurrection]

GHC/Cmm/Info/Build.hs:405 compiler 2 tickets

The "static flag" mechanism (see Note [STATIC_LINK fields] in smStorage.h) that
the GC uses to track liveness of static objects assumes that unreachable
objects will never become reachable again (i.e. are never "resurrected").
Breaking this assumption can result in extremely subtle GC soundness issues
(e.g. #15544, #20959).

Guaranteeing that this assumption is not violated requires that all CAFfy
static objects reachable from the object's code are reachable from its SRT.  In
the past we have gotten this wrong in a few ways:

 * shortcutting references to FUN_STATICs to instead point to the FUN_STATIC's
   SRT. This lead to #15544 and is described in more detail in Note [Invalid
   optimisation: shortcutting].

 * omitting references to static data constructor applications. This previously
   happened due to an oversight (#20959): when generating an SRT for a
   recursive group we would drop references to the CAFfy static data
   constructors.

To see why we cannot allow object resurrection, see the examples in the
above-mentioned Notes.

If a static closure definitely does not transitively refer to any CAFs, then it
*may* be advertised as not-CAFfy in the interface file and consequently *may*
be omitted from SRTs. Regardless of whether the closure is advertised as CAFfy
or non-CAFfy, its STATIC_LINK field *must* be set to 3, so that it never
appears on the static closure list.

References 1

Referenced by 3