7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76

There is a race between one thread successfully forwarding and copying the klass mirror for the SoftReference class (including the static master clock) and another thread attempting to use the master clock while attempting to discover a soft reference object. Maintain a shadow copy of the soft reference master clock and use the shadow during reference discovery and reference processing.

Reviewed-by: tonyp, brutisso, ysr
This commit is contained in:
John Cuthbertson 2011-10-12 10:25:51 -07:00
parent 7fa7f8a597
commit 4738ed88a5
4 changed files with 75 additions and 33 deletions

View file

@ -201,7 +201,6 @@ public:
assert(_ref != _first_seen, "cyclic ref_list found");
NOT_PRODUCT(_processed++);
}
};
class ReferenceProcessor : public CHeapObj {
@ -209,6 +208,9 @@ class ReferenceProcessor : public CHeapObj {
// Compatibility with pre-4965777 JDK's
static bool _pending_list_uses_discovered_field;
// The SoftReference master timestamp clock
static jlong _soft_ref_timestamp_clock;
MemRegion _span; // (right-open) interval of heap
// subject to wkref discovery
@ -456,19 +458,7 @@ class ReferenceProcessor : public CHeapObj {
void set_span(MemRegion span) { _span = span; }
// start and stop weak ref discovery
void enable_discovery(bool verify_disabled, bool check_no_refs) {
#ifdef ASSERT
// Verify that we're not currently discovering refs
assert(!verify_disabled || !_discovering_refs, "nested call?");
if (check_no_refs) {
// Verify that the discovered lists are empty
verify_no_references_recorded();
}
#endif // ASSERT
_discovering_refs = true;
}
void enable_discovery(bool verify_disabled, bool check_no_refs);
void disable_discovery() { _discovering_refs = false; }
bool discovery_enabled() { return _discovering_refs; }