Opened 7 years ago

Last modified 20 months ago

#3946 new task

Better diagnostic when entering a GC'd CAF

Reported by: simonmar Owned by:
Priority: low Milestone:
Component: Runtime System Version: 6.12.1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


Currently a GC'd CAF contains a dangling pointer, so entering it will result in a segfault or some other random failure. It would be better to give a useful diagnostic in this case (see #3900), not only to detect when keepCAFs is needed, but also to help find bugs in the code generator's SRT table generation and GC bugs.

Here is one way it could be done. We use the static link field of a static closure to indicate whether the closure is live or not:

  • link field is non-zero if and only if the closure was reachable at the last GC, otherwise it is zero

if an IND_STATIC closure has a zero link field, then we know for sure that the closure pointed to by the IND_STATIC is invalid and entering the IND_STATIC should give a helpful error message.

To implement this:

  • on entering a CAF, set the link field to 1.
  • at the beginning of (major) GC, set all the link fields for static closures that were reachable during the last major GC to zero
  • during GC, link fields for reachable static closures get set to non-zero as they are linked onto first the static_objects list and then the scavenged_static_objects list.

One problem is that this scheme means traversing and writing to all the static closures at the beginning of GC, when some of them may be dead, and many will not be in the cache. The current way of doing this at the end of GC is better from a cache perspective. To refine the above approach, we could do the extra zeroing phase at the beginning of GC for IND_STATIC closures only, and the others would get the current treatment.

Change History (9)

comment:1 Changed 7 years ago by igloo


comment:2 Changed 7 years ago by igloo


comment:3 Changed 6 years ago by igloo


comment:4 Changed 6 years ago by igloo

Priority: normallow

comment:5 Changed 5 years ago by igloo


comment:6 Changed 3 years ago by thoughtpolice


Moving to 7.10.1.

comment:7 Changed 3 years ago by thoughtpolice


Moving to 7.12.1 milestone; if you feel this is an error and should be addressed sooner, please move it back to the 7.10.1 milestone.

comment:8 Changed 2 years ago by thoughtpolice


Milestone renamed

comment:9 Changed 20 months ago by thomie

Milestone: 8.0.1
Note: See TracTickets for help on using tickets.