MPS issue job001666

TitleNo guarantee that all weak references to an object die together.
Statusopen
Priorityoptional
Assigned userRichard Brooksby
OrganizationRavenbrook
DescriptionNo guarantee that all weak references to an object die together.

When there are multiple weak references to some object X it is
reasonable for a client to require that all such references get
splatted atomically (from the viewpoint of the client).

We currently don't implement such a guarantee. Though we almost do.

In fact a stronger requirement is reasonable: That when weak references
to an object X get splatted it is not possible reach X from some other
(weakly referenced) object. The JLS [2] says something equivalent and
probably more precise: "At that time it will atomically clear all weak
references to that object and all weak references to any other
weakly-reachable objects from which that object is reachable through a
chain of strong and soft references"

job001665 concerns the lack of documentation of weakness.

job001676 concerns AMC in emergency mode when it may also fail to splat
a weak reference.
AnalysisSee [1]. We fail to implement the guarantee when the mutator reads a
weak reference and the tracer has already scanned and splatted some
other weak reference to the same object. In this case the weak
reference being read by the mutator will not be splatted. The result
is that only some of the weak references to an object will be splatted.

That's because currently a barrier hit always scans as if at RankEXACT.
See [3] and TraceSegAccess in trace.c.

A fix for this will be easier once job001658 is fixed. The trace needs
to be aware of which rank state it is in; when the trace is in "weak
state" and a barrier hit occurs on a RankWEAK segment then the
reference should be scanned as if at RankWEAK.

It turns out that the stronger guarantee "just drops out" from the
implementation.

2007-07-03 DRJ:

There are useful assertions we can make about the state of the
tracer when we get a barrier hit. For example, we can assert
that TraceBand != RankAMBIG. See [4]. Fixing this problem with a
change might be a good time to add some asserts.

Changelist 179210 scans weak segments weakly when the trace is in the weak band, significantly increasing the chance that all weak references to an object will die together. However, we still sometimes fall back to exact scanning when a weak segment is getting hammered by the mutator (as has been observed in Open Dylan). See AWLHaveSegSALimit in poolawl.c. So we still can't make a *guarantee*. RB 2012-09-21
How foundunknown
Evidence[1] //info.ravenbrook.com/mail/2007/06/26/11-48-09/0.txt e-mail from rhsk@ravenbrook.com
[2] http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ref/WeakReference.html
[3] //info.ravenbrook.com/mail/2007/06/25/15-23-12/0.txt e-mail from rhsk@ravenbrook.com
[4] //info.ravenbrook.com/mail/2007/06/26/11-17-07/0.txt e-mail from RHSK
Observed in1.107.0
Created byDavid Jones
Created on2007-06-27 13:07:30
Last modified byGareth Rees
Last modified on2013-03-19 11:59:38
History2007-06-27 DRJ Created.
2007-07-03 DRJ Add note about asserts.
2007-07-11 DRJ Link to job001676
2012-09-21 RB Linked changelist 179210 and added explanation.
2013-03-19 GDR Assigned to RB.

Fixes

Change Effect Date User Description
179210 open 2012-09-03 17:05:51 David Lovemore Fix weak band assert. We now trace weak segments as weak on a fault if we are in the weak band.