RFR: 8296324: JVMTI GetStackTrace truncates vthread stack trace for agents loaded into running VM [v2]
Serguei Spitsyn
sspitsyn at openjdk.org
Fri Nov 18 05:04:53 UTC 2022
On Fri, 18 Nov 2022 03:43:34 GMT, Chris Plummer <cjplummer at openjdk.org> wrote:
>> If `notify_jvmti_events()` is false, then you call `set_notify_jvmti_events(true)`, which means you will never enter the `if` block again. However, if the thread is not attached, you do not call `init_static_notify_jvmti_events()`. What happens if later there is an attached thread that triggers this code? Is seem when that happens you should call `init_static_notify_jvmti_events()`, but won't because `notify_jvmti_events()` is true.
>
> I think you need a flag that tells you if `init_static_notify_jvmti_events()` has been called.
A part of the initialization sequence we need to know is:
create_vm() {
. . .
// Launch -agentlib/-agentpath and converted -Xrun agents
if (Arguments::init_agents_at_startup()) {
create_vm_init_agents(); => {
<loads all agents and calls AgentOnLoad entry points> =>
get_jvmti_interface() => set_notify_jvmti_events(true)
}
. . .
init_globals() => javaClasses_init() => java_lang_VirtualThread::init_static_notify_jvmti_events()
The `create_vm_init_agents()` is called in the context of unattaching thread.
In this context a call to `java_lang_VirtualThread::init_static_notify_jvmti_events()` is guaranteed to happen after all the agents were successfully loaded at startup and executed their `AgentOnLoad` entree points which make calls to `vm->GetEnv()` that transitively call to `get_jvmti_interface()` and `java_lang_VirtualThread::set_notify_jvmti_events(true)`.
We can add a comment on this but I'm puzzled on how to make it clear and simple.
-------------
PR: https://git.openjdk.org/jdk/pull/11204
More information about the hotspot-dev
mailing list