Skip to content

Commit 90f85ff

Browse files
author
Markus Grönlund
committed
8271588: JFR Recorder Thread crashed with SIGSEGV in write_klass
Reviewed-by: egahlin
1 parent f312f28 commit 90f85ff

5 files changed

Lines changed: 17 additions & 7 deletions

File tree

src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ size_t JfrCheckpointManager::flush_type_set() {
455455
elements = ::flush_type_set(thread);
456456
}
457457
}
458-
if (_new_checkpoint.is_signaled()) {
458+
if (_new_checkpoint.is_signaled_with_reset()) {
459459
WriteOperation wo(_chunkwriter);
460460
MutexedWriteOperation mwo(wo);
461461
_thread_local_mspace->iterate(mwo); // current epoch list

src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeSet.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,6 +1103,10 @@ void JfrTypeSet::clear() {
11031103
}
11041104

11051105
size_t JfrTypeSet::on_unloading_classes(JfrCheckpointWriter* writer) {
1106+
// JfrTraceIdEpoch::has_changed_tag_state_no_reset() is a load-acquire we issue to see side-effects (i.e. tags).
1107+
// The JfrRecorderThread does this as part of normal processing, but with concurrent class unloading, which can
1108+
// happen in arbitrary threads, we invoke it explicitly.
1109+
JfrTraceIdEpoch::has_changed_tag_state_no_reset();
11061110
if (JfrRecorder::is_recording()) {
11071111
return serialize(writer, NULL, true, false);
11081112
}

src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ class JfrTraceIdEpoch : AllStatic {
108108
}
109109

110110
static bool has_changed_tag_state() {
111+
return _tag_state.is_signaled_with_reset();
112+
}
113+
114+
static bool has_changed_tag_state_no_reset() {
111115
return _tag_state.is_signaled();
112116
}
113117

src/hotspot/share/jfr/recorder/stringpool/jfrStringPool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ typedef JfrStringPool::BufferPtr BufferPtr;
4444
static JfrSignal _new_string;
4545

4646
bool JfrStringPool::is_modified() {
47-
return _new_string.is_signaled();
47+
return _new_string.is_signaled_with_reset();
4848
}
4949

5050
static JfrStringPool* _instance = NULL;

src/hotspot/share/jfr/utilities/jfrSignal.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ class JfrSignal {
3434
JfrSignal() : _signaled(false) {}
3535

3636
void signal() const {
37-
if (!Atomic::load_acquire(&_signaled)) {
38-
Atomic::release_store(&_signaled, true);
39-
}
37+
Atomic::release_store(&_signaled, true);
4038
}
4139

4240
bool is_signaled() const {
43-
if (Atomic::load_acquire(&_signaled)) {
44-
Atomic::release_store(&_signaled, false); // auto-reset
41+
return Atomic::load_acquire(&_signaled);
42+
}
43+
44+
bool is_signaled_with_reset() const {
45+
if (is_signaled()) {
46+
Atomic::release_store(&_signaled, false);
4547
return true;
4648
}
4749
return false;

0 commit comments

Comments
 (0)