# HG changeset patch # User aph # Date 1560439071 -3600 # Thu Jun 13 16:17:51 2019 +0100 # Node ID a2906ba6352430b23dcb3cd8bf018ed8b6121e9f # Parent 8b8d83cf9097fd97b359d7a19583e81d822eebcd 8225716: G1 GC: Undefined behaviour in G1BlockOffsetTablePart::block_at_or_preceding Reviewed-by: duke diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp @@ -65,7 +65,7 @@ inline u_char offset_array(size_t index) const; void set_offset_array_raw(size_t index, u_char offset) { - _offset_array[index] = offset; + Atomic::store(offset, &_offset_array[index]); } inline void set_offset_array(size_t index, u_char offset); diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp --- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp +++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.inline.hpp @@ -51,7 +51,7 @@ u_char G1BlockOffsetTable::offset_array(size_t index) const { check_index(index, "index out of range"); - return _offset_array[index]; + return Atomic::load(&_offset_array[index]); } void G1BlockOffsetTable::set_offset_array(size_t index, u_char offset) {