Skip to content
New issue

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

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

Already on GitHub? # to your account

Dumping the Bytecode Fails #11918

Open
1 task done
DaGeRe opened this issue Jan 7, 2025 · 1 comment
Open
1 task done

Dumping the Bytecode Fails #11918

DaGeRe opened this issue Jan 7, 2025 · 1 comment

Comments

@DaGeRe
Copy link
Contributor

DaGeRe commented Jan 7, 2025

Prerequisites

Please check the FAQ, and search existing issues for similar questions before creating a new issue.YOU MAY DELETE THIS PREREQUISITES SECTION.

  • I have checked the FAQ, and issues and found no answer.

What version of pinpoint are you using?

v3.0.1 on OpenJDK 17

Describe the bug

When trying to dump the bytecode of the instrumented classes, I receive:

01-07 13:43:55.055 [ main] WARN c.n.p.p.i.l.DefaultLambdaBytecodeHandler -- lambda transform fail Caused by:classInternalName
java.lang.NullPointerException: classInternalName
at java.util.Objects.requireNonNull(Objects.java:235) ~[?:?]
at com.navercorp.pinpoint.profiler.instrument.ASMBytecodeDumpService.dumpBytecode(ASMBytecodeDumpService.java:89) ~[pinpoint-profiler-3.0.1.jar:3.0.1]
at com.navercorp.pinpoint.profiler.instrument.BytecodeDumpTransformer.transform(BytecodeDumpTransformer.java:41) ~[pinpoint-profiler-3.0.1.jar:3.0.1]
at com.navercorp.pinpoint.profiler.context.javamodule.ClassFileTransformerModuleHandler.transform(ClassFileTransformerModuleHandler.java:56) ~[pinpoint-profiler-3.0.1.jar:3.0.1]
at com.navercorp.pinpoint.profiler.instrument.lambda.DefaultLambdaBytecodeHandler.handleLambdaBytecode(DefaultLambdaBytecodeHandler.java:47) [pinpoint-profiler-3.0.1.jar:3.0.1]
at com.navercorp.pinpoint.profiler.instrument.lambda.LambdaBytecodeLogger.handleLambdaBytecode(LambdaBytecodeLogger.java:45) [pinpoint-profiler-3.0.1.jar:3.0.1]
at com.navercorp.pinpoint.bootstrap.java16.lambda.MethodHandlesLookupDelegatorJava16.defineHiddenClass(MethodHandlesLookupDelegatorJava16.java:44) [?:3.0.1]
at java.lang.invoke.InnerClassLambdaMetafactory.generateInnerClass(InnerClassLambdaMetafactory.java:407) [?:?]
at java.lang.invoke.InnerClassLambdaMetafactory.spinInnerClass(InnerClassLambdaMetafactory.java:315) [?:?]
at java.lang.invoke.InnerClassLambdaMetafactory.buildCallSite(InnerClassLambdaMetafactory.java:228) [?:?]
at java.lang.invoke.LambdaMetafactory.metafactory(LambdaMetafactory.java:341) [?:?]
at java.lang.invoke.BootstrapMethodInvoker.invoke(BootstrapMethodInvoker.java:134) [?:?]
at java.lang.invoke.CallSite.makeSite(CallSite.java:315) [?:?]
at java.lang.invoke.MethodHandleNatives.linkCallSiteImpl(MethodHandleNatives.java:281) [?:?]
at java.lang.invoke.MethodHandleNatives.linkCallSite(MethodHandleNatives.java:271) [?:?]
at org.springframework.boot.SpringApplicationRunListeners.ready(SpringApplicationRunListeners.java:82) [spring-boot-2.7.17.jar!/:2.7.17]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:323) [spring-boot-2.7.17.jar!/:2.7.17]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1300) [spring-boot-2.7.17.jar!/:2.7.17]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1289) [spring-boot-2.7.17.jar!/:2.7.17]
at com.navercorp.pinpoint.testapp.TestApp.main(TestApp.java:30) [!/:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]

What did you do to trigger the bug?

I changed bytecode.dump.enable=false to bytecode.dump.enable=true in pinpoint-agent-3.0.1/profiles/release/pinpoint.config

Also using profiler.lambda.expressions.support=false doesn't disable this behavior (but I would expect this to stop the instrumentation of lambda expressions).

Expected behavior

I expect some .class files that can be used for further debugging.

Additional context

I am trying to debug the behavior described in #11880

@emeroad
Copy link
Member

emeroad commented Jan 8, 2025

In general, it is not possible for classInternalName to be null.
As a special case, classInternalName may be null for a Lambda class, in which case no bytecode is provided and dumping is not possible,
If a bytecode is provided, the class name must be obtained by parsing the bytecode.

https://github.com/pinpoint-apm/pinpoint/blob/master/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/javamodule/ClassFileTransformerModuleHandler.java#L87

   private static String ensureClassName(String className, byte[] classfileBuffer) {
        if (className != null) {
            return className;
        }
        return readClassName(classfileBuffer); <- Lambda class
    }

    private static String readClassName(byte[] classfileBuffer) {
        String className = new ClassReaderWrapper(classfileBuffer).getClassInternalName();
        return JavaAssistUtils.jvmNameToJavaName(className);
    }

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants