Opened 5 years ago

Last modified 7 months ago

#3946 new task

Better diagnostic when entering a GC'd CAF

Reported by: simonmar Owned by:
Priority: low Milestone: 7.12.1
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 Revisions:

Description

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 (7)

comment:1 Changed 5 years ago by igloo

  • Milestone changed from 7.0.1 to 7.0.2

comment:2 Changed 4 years ago by igloo

  • Milestone changed from 7.0.2 to 7.2.1

comment:3 Changed 4 years ago by igloo

  • Milestone changed from 7.2.1 to 7.4.1

comment:4 Changed 3 years ago by igloo

  • Milestone changed from 7.4.1 to 7.6.1
  • Priority changed from normal to low

comment:5 Changed 3 years ago by igloo

  • Milestone changed from 7.6.1 to 7.6.2

comment:6 Changed 13 months ago by thoughtpolice

  • Milestone changed from 7.6.2 to 7.10.1

Moving to 7.10.1.

comment:7 Changed 7 months ago by thoughtpolice

  • Milestone changed from 7.10.1 to 7.12.1

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.

Note: See TracTickets for help on using tickets.