Skip to content

8362203: assert(state == nullptr || state->get_thread_oop() != nullptr) failed: incomplete state #26303

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/hotspot/share/prims/jvmtiExport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,13 @@ void JvmtiExport::post_early_vm_start() {
void JvmtiExport::post_vm_start() {
EVT_TRIG_TRACE(JVMTI_EVENT_VM_START, ("Trg VM start event triggered" ));

// The JvmtiThreadState is incomplete if initialized in post_early_vm_start
// before classes are initialized. It should be updated now.
JavaThread *thread = JavaThread::current();
if (thread->jvmti_thread_state() != nullptr) {
thread->jvmti_thread_state()->update_thread_oop_during_vm_start();
}

// can now enable some events
JvmtiEventController::vm_start();

Expand All @@ -684,7 +691,6 @@ void JvmtiExport::post_vm_start() {
if (!env->early_vmstart_env() && env->is_enabled(JVMTI_EVENT_VM_START)) {
EVT_TRACE(JVMTI_EVENT_VM_START, ("Evt VM start event sent" ));

JavaThread *thread = JavaThread::current();
JvmtiThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
jvmtiEventVMStart callback = env->callbacks()->VMStart;
Expand Down
7 changes: 7 additions & 0 deletions src/hotspot/share/prims/jvmtiThreadState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,13 @@ oop JvmtiThreadState::get_thread_oop() {
return _thread_oop_h.resolve();
}

void JvmtiThreadState::update_thread_oop_during_vm_start() {
assert(_thread->threadObj() != nullptr, "santity check");
if (get_thread_oop() == nullptr) {
_thread_oop_h.replace(_thread->threadObj());
}
}

void JvmtiThreadState::set_thread(JavaThread* thread) {
_thread_saved = nullptr; // Common case.
if (!_is_virtual && thread == nullptr) {
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/prims/jvmtiThreadState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ class JvmtiThreadState : public CHeapObj<mtInternal> {
void set_thread(JavaThread* thread);
oop get_thread_oop();

void update_thread_oop_during_vm_start();

inline bool is_virtual() { return _is_virtual; } // the _thread is virtual

inline bool is_exception_detected() { return _exception_state == ES_DETECTED; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2025, 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
Expand All @@ -23,12 +23,13 @@

/**
* @test
* @bug 8172970
* @bug 8172970 8362203
* @summary Verify the functions that are allowed to operate in the start phase
* with and without can_generate_early_vmstart capability.
* @requires vm.jvmti
* @run main/othervm/native -agentlib:AllowedFunctions AllowedFunctions
* @run main/othervm/native -agentlib:AllowedFunctions=with_early_vmstart AllowedFunctions
* @run main/othervm/native -agentlib:AllowedFunctions=with_early_vmstart -Xrunjdwp:transport=dt_socket,address=0,server=y,suspend=n AllowedFunctions
*/

public class AllowedFunctions {
Expand Down