Skip to content

Commit 1bd0ce1

Browse files
author
William Kemper
committedMar 27, 2025
8352918: Shenandoah: Verifier does not deactivate barriers as intended
Reviewed-by: kdnilsen, shade, ysr
1 parent dc5c414 commit 1bd0ce1

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
 

‎src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,19 @@
4646

4747
ShenandoahGCStateResetter::ShenandoahGCStateResetter() :
4848
_heap(ShenandoahHeap::heap()),
49-
_gc_state(_heap->gc_state()) {
49+
_saved_gc_state(_heap->gc_state()),
50+
_saved_gc_state_changed(_heap->_gc_state_changed) {
51+
// Clear state to deactivate barriers. Indicate that state has changed
52+
// so that verifier threads will use this value, rather than thread local
53+
// values (which we are _not_ changing here).
5054
_heap->_gc_state.clear();
55+
_heap->_gc_state_changed = true;
5156
}
5257

5358
ShenandoahGCStateResetter::~ShenandoahGCStateResetter() {
54-
_heap->_gc_state.set(_gc_state);
55-
assert(_heap->gc_state() == _gc_state, "Should be restored");
59+
_heap->_gc_state.set(_saved_gc_state);
60+
_heap->_gc_state_changed = _saved_gc_state_changed;
61+
assert(_heap->gc_state() == _saved_gc_state, "Should be restored");
5662
}
5763

5864
void ShenandoahRootVerifier::roots_do(OopIterateClosure* oops) {

‎src/hotspot/share/gc/shenandoah/shenandoahRootVerifier.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
class ShenandoahGCStateResetter : public StackObj {
3333
private:
3434
ShenandoahHeap* const _heap;
35-
const char _gc_state;
35+
const char _saved_gc_state;
36+
const bool _saved_gc_state_changed;
3637

3738
public:
3839
ShenandoahGCStateResetter();

0 commit comments

Comments
 (0)
Please sign in to comment.