apache / skywalking

APM, Application Performance Monitoring System
https://skywalking.apache.org/
Apache License 2.0
23.85k stars 6.53k forks source link

got NPE with undertow plugin #7227

Closed mis98zb closed 3 years ago

mis98zb commented 3 years ago

Please answer these questions before submitting your issue.


Bug

skywalking files:

│  skywalking-agent.jar
│
├─activations
│      apm-toolkit-log4j-1.x-activation-8.6.0.jar
│      apm-toolkit-log4j-2.x-activation-8.6.0.jar
│      apm-toolkit-logback-1.x-activation-8.6.0.jar
│      apm-toolkit-logging-common-8.6.0.jar
│      apm-toolkit-trace-activation-8.6.0.jar
│
├─config
│      agent.config
│
└─plugins
        apm-ehcache-2.x-plugin-8.6.0.jar
        apm-feign-default-http-9.x-plugin-8.6.0.jar
        apm-httpClient-4.x-plugin-8.6.0.jar
        apm-httpclient-commons-8.6.0.jar
        apm-jdbc-commons-8.6.0.jar
        apm-jetty-client-9.x-plugin-8.6.0.jar
        apm-lettuce-5.x-plugin-8.6.0.jar
        apm-mybatis-3.x-plugin-8.6.0.jar
        apm-mysql-8.x-plugin-8.6.0.jar
        apm-mysql-commons-8.6.0.jar
        apm-netty-socketio-plugin-8.6.0.jar
        apm-okhttp-3.x-plugin-8.6.0.jar
        apm-okhttp-4.x-plugin-8.6.0.jar
        apm-okhttp-common-8.6.0.jar
        apm-quartz-scheduler-2.x-plugin-8.6.0.jar
        apm-resttemplate-4.3.x-plugin-8.6.0.jar
        apm-spring-annotation-plugin-8.6.0.jar
        apm-spring-async-annotation-plugin-8.6.0.jar
        apm-spring-cloud-gateway-3.x-plugin-8.6.0.jar
        apm-spring-concurrent-util-4.x-plugin-8.6.0.jar
        apm-spring-core-patch-8.6.0.jar
        apm-spring-scheduled-annotation-plugin-8.6.0.jar
        apm-spring-tx-plugin-8.6.0.jar
        apm-spring-webflux-5.x-plugin-8.6.0.jar
        apm-springmvc-annotation-5.x-plugin-8.6.0.jar
        apm-springmvc-annotation-commons-8.6.0.jar
        apm-undertow-2.x-plugin-8.6.0.jar
        resteasy-server-3.x-plugin-8.6.0.jar
        spring-commons-8.6.0.jar
        spring-webflux-5.x-webclient-plugin-8.6.0.jar

We got plenty of NPEs as below:

2021-07-02 11:14:55.578 70224209 [XNIO-1 task-2] ERROR org.jboss.threads.errors - [TID:N/A] - Thread Thread[XNIO-1 task-2,5,main] threw an uncaught exception
java.lang.NullPointerException: null
    at org.apache.skywalking.apm.agent.core.context.ContextManager.stopSpan(ContextManager.java:186)
    at org.apache.skywalking.apm.plugin.undertow.v2x.SWRunnable.run(SWRunnable.java:47)
    at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
    at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2019)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1558)
    at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1449)
    at java.base/java.lang.Thread.run(Unknown Source)
wu-sheng commented 3 years ago

I think we didn't test in jboss, check the supported list, I think it is not there.

From the logs, the possibility is this undertow.v2x.SWRunnable running in an expected thread, which doesn't have been instrumented, so no span to stop.

mis98zb commented 3 years ago

Thank you for the effort.

To add more details, I'm using springboot with undertow embed, and using RESTEasy as the web framework. The app jar is running inside a docker image based on openjdk:11.0.9.1-jre, with customized skywalking agent folder.