open-telemetry / open-telemetry/opentelemetry-java-instrumentation

Opentelemetry javaagent crashsed with DCEVM, due to StackOverflow caused by endless loadHelperClass.

Open
#14,426 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs triage
Dominant language
Java
Stars
2.6k
Forks
1.2k
Avg merge
2d 18h
Merged PRs (30d)
228

Description

Describe the bug

When using with DCEVM, OpenTelemetry javaagent failed to start, with error logs:

Exception in thread "main" java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
	at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.StackOverflowError
	at io.opentelemetry.javaagent.bootstrap.InjectedClassHelper.loadHelperClass(InjectedClassHelper.java:55)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at io.opentelemetry.javaagent.bootstrap.InjectedClassHelper.loadHelperClass(InjectedClassHelper.java:55)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ...... (many lines in loop)
	at io.opentelemetry.javaagent.OpenTelemetryAgent.startAgent(OpenTelemetryAgent.java:57)
	at io.opentelemetry.javaagent.OpenTelemetryAgent.premain(OpenTelemetryAgent.java:45)
	at com.yuanfudao.opentelemetry.javaagent.YuanfudaoAgent.premain(YuanfudaoAgent.java:14)
	... 6 more
FATAL ERROR in native method: processing of -javaagent failed
Steps to reproduce
Expected behavior

It should start normally.

Actual behavior

It crashes.

Javaagent or library instrumentation version

v2.12.0

Environment

JDK: 8
OS: CentOS amd64

Additional context

If I use invokedynamic, it will crash with:

Exception in thread "BatchSpanProcessor_WorkerThread-1" java.lang.BootstrapMethodError: call site initialization exception
	at java.lang.invoke.CallSite.makeSite(CallSite.java:341)
	at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:307)
	at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:297)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
	at io.opentelemetry.sdk.trace.export.BatchSpanProcessor$Worker.run(BatchSpanProcessor.java:255)
	at java.lang.Thread.run(Thread.java:750)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class io.opentelemetry.javaagent.bootstrap.ExceptionLogger
	at io.opentelemetry.javaagent.bootstrap.IndyBootstrapDispatcher.bootstrap(IndyBootstrapDispatcher.java:45)
	at java.lang.invoke.CallSite.makeSite(CallSite.java:306)
	... 5 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
	at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.BootstrapMethodError: call site initialization exception
	at java.lang.invoke.CallSite.makeSite(CallSite.java:341)
	at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:307)
	at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:297)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:352)
	at io.opentelemetry.javaagent.OpenTelemetryAgent.startAgent(OpenTelemetryAgent.java:57)
	at io.opentelemetry.javaagent.OpenTelemetryAgent.premain(OpenTelemetryAgent.java:45)
	at com.yuanfudao.opentelemetry.javaagent.YuanfudaoAgent.premain(YuanfudaoAgent.java:14)
	... 6 more
Caused by: java.lang.NoClassDefFoundError: Could not initialize class io.opentelemetry.javaagent.bootstrap.ExceptionLogger
	at io.opentelemetry.javaagent.bootstrap.IndyBootstrapDispatcher.bootstrap(IndyBootstrapDispatcher.java:45)
	at java.lang.invoke.CallSite.makeSite(CallSite.java:306)
	... 12 more
Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with io.opentelemetry.javaagent.bootstrap.InjectedClassHelper.loadHelperClass at line 55 and trace the recursive ClassLoader.loadClass loop shown in the stack trace. Compare the startup path through OpenTelemetryAgent.startAgent and the invokedynamic path through IndyBootstrapDispatcher. Done means the agent starts normally on patched JDK 8 with DCEVM and does not produce the reported StackOverflowError or BootstrapMethodError.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.