# HG changeset patch # User tschatzl # Date 1453385705 -3600 # Node ID 71f6bbeb6026625903a721be4934eba67338a697 # Parent f3f2f71d2dc8e720fd88227277c2be0af45c9b73 8147087: Race when reusing PerRegionTable bitmaps may result in dropped remembered set entries Summary: Do not make reused PRTs available to other threads before the bitmap of the PRT has been cleared. Reviewed-by: tbenson, mgerdin, brutisso Contributed-by: Poonam Bajaj , Thomas Schatzl diff -r f3f2f71d2dc8 -r 71f6bbeb6026 src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp --- a/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Tue Jan 19 18:16:40 2016 +0000 +++ b/src/share/vm/gc_implementation/g1/heapRegionRemSet.cpp Thu Jan 21 15:15:05 2016 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -119,7 +119,9 @@ public: - HeapRegion* hr() const { return _hr; } + HeapRegion* hr() const { + return (HeapRegion*) OrderAccess::load_ptr_acquire(&_hr); + } jint occupied() const { // Overkill, but if we ever need it... @@ -132,10 +134,12 @@ set_next(NULL); set_prev(NULL); } - _hr = hr; _collision_list_next = NULL; _occupied = 0; _bm.clear(); + // Make sure that the bitmap clearing above has been finished before publishing + // this PRT to concurrent threads. + OrderAccess::release_store_ptr(&_hr, hr); } void add_reference(OopOrNarrowOopStar from) { @@ -441,7 +445,7 @@ if (G1TraceHeapRegionRememberedSet) { gclog_or_tty->print_cr(" from-card cache hit."); } - assert(contains_reference(from), "We just added it!"); + assert(contains_reference(from), err_msg("We just found " PTR_FORMAT " in the FromCardCache", from)); return; } @@ -454,7 +458,7 @@ if (G1TraceHeapRegionRememberedSet) { gclog_or_tty->print_cr(" coarse map hit."); } - assert(contains_reference(from), "We just added it!"); + assert(contains_reference(from), err_msg("We just found " PTR_FORMAT " in the Coarse table", from)); return; } @@ -488,7 +492,7 @@ if (G1TraceHeapRegionRememberedSet) { gclog_or_tty->print_cr(" added card to sparse table."); } - assert(contains_reference_locked(from), "We just added it!"); + assert(contains_reference_locked(from), err_msg("We just added " PTR_FORMAT " to the Sparse table", from)); return; } else { if (G1TraceHeapRegionRememberedSet) { @@ -547,7 +551,7 @@ hr()->bottom(), from); } } - assert(contains_reference(from), "We just added it!"); + assert(contains_reference(from), err_msg("We just added " PTR_FORMAT " to the PRT", from)); } PerRegionTable*