Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit

Permalink
8247967: SparkExamples24H.java SIGSEGV in various places
Browse files Browse the repository at this point in the history
Reviewed-by: dcubed, dholmes
  • Loading branch information
Markus Grönlund committed Jun 23, 2020
1 parent e66a2a3 commit 4bcd70a
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,34 +427,26 @@ void JfrCheckpointManager::on_unloading_classes() {
}
}

class JavaThreadToVM : public StackObj {
private:
JavaThread* _jt;
public:
JavaThreadToVM(Thread* thread) : _jt(thread->is_Java_thread() ? (JavaThread*)thread : NULL) {
if (_jt != NULL) {
assert(_jt->thread_state() == _thread_in_native, "invariant");
_jt->set_thread_state(_thread_in_vm);
}
}
~JavaThreadToVM() {
if (_jt != NULL) {
_jt->set_thread_state(_thread_in_native);
}
}
};
static size_t flush_type_set(Thread* thread) {
assert(thread != NULL, "invariant");
JfrCheckpointWriter writer(thread);
MutexLocker cld_lock(thread, ClassLoaderDataGraph_lock);
MutexLocker module_lock(thread, Module_lock);
return JfrTypeSet::serialize(&writer, NULL, false, true);
}

size_t JfrCheckpointManager::flush_type_set() {
size_t elements = 0;
if (JfrTraceIdEpoch::has_changed_tag_state()) {
Thread* const t = Thread::current();
// can safepoint here (if JavaThread)
JavaThreadToVM transition(t);
ResetNoHandleMark rnhm;
MutexLocker cld_lock(t, ClassLoaderDataGraph_lock);
MutexLocker module_lock(t, Module_lock);
JfrCheckpointWriter writer(t);
elements = JfrTypeSet::serialize(&writer, NULL, false, true);
Thread* const thread = Thread::current();
if (thread->is_Java_thread()) {
// can safepoint here
ThreadInVMfromNative transition((JavaThread*)thread);
ResetNoHandleMark rnhm;
elements = ::flush_type_set(thread);
} else {
elements = ::flush_type_set(thread);
}
}
if (is_constant_pending()) {
WriteOperation wo(_chunkwriter);
Expand Down

0 comments on commit 4bcd70a

Please sign in to comment.