Skip to content

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

@h0cheung

Description

@h0cheung

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds triageNew issue that requires triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions