-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix UnsupportedOperationException with debugger agent + retransforming agent #1528
Conversation
Also, while we haven't been able to formally test this, instrumenting the debugger agent itself with our APM agent allowed us to experiment and try to make the debugger agent instrument again, which gives us confidence that this fix allows to fix the observed issue. |
I mentioned this to them a long time ago, but unfortunately, they never took the issue seriously. |
Hi, thanks for your contribution! |
I don’t know how to say you guys are stupid. I don't care if this pr will eventually be merged, I've already implemented my own equivalent replacement. Is there even one person in the entire JetBrains company who understands the behavior of Instrumentation? |
Thanks @gorrus for the link on the related issue. In https://youtrack.jetbrains.com/issue/IDEA-206160, the last comment indicates that the issue might be related to using Byte Buddy, whereas in practice I don't think it's not specific to Byte Buddy but could also happen with any re-transforming agent. The question here is to know if there any side-effect of applying class modification more than once with the debugger agent. Thus, if you can find more information/context on this change from ~2 years ago, that could definitely help here. |
@SylvainJuge I think you should look at my link(https://youtrack.jetbrains.com/issue/IDEA-224714). |
@NekoCaffeine Please refrain from using rude language and keep the conversation civil. Blaming JetBrains employees is non-constructive and won't help to resolve the issue in any way. Thank you. |
Ban me as JetBrains if you can. Haha. |
As @NekoCaffeine mentioned, the issue is well described in https://youtrack.jetbrains.com/issue/IDEA-224714.
For now I can propose to detect "untransformed" classes on agent start, smth like:
and then "skip" them during the transform: |
implemented this in d397917, please try |
Hi @gorrus , sorry for not giving you feedback on this sooner. I tried re-building the whole project, but I could not see if the agent version I built was working as expected here (I just got a similar behavior as the one reported in the issue), but that might definitely be due to a keyboard-and-chair issue here. I'm not really familiar with building the whole project from scratch, is there a quick way to only recompile and package only the debugger agent ? |
@SylvainJuge there's no need to build the whole project, find action "Build Artifacts" and choose debugger-agent. Then you can take the agent from out\classes\artifacts\debugger_agent and replace it in the existing installation. |
IDEA debugger agent instruments classes by modifying their structure, which is allowed before the classes are loaded for the first time.
However, when another agent tries to instrument by re-transforming one of the classes already instrumented by the debugger agent, we get
UnsupportedOperationException
as the modified class bytecode is not provided to the other agent.We discovered this in the context of elastic/apm-agent-java#1673 where
java.util.concurrent.ForkJoinTask#fork()
is instrumented both by IDEA debugger agent and Elastic APM agent.While we can apply a simple work-around like checking if
intellij.debug.agent
system property is being set and invite anyone debugging with the debugger agent active to disable it, it is definitely just a work-around and prevents us from using this very useful debugger feature. Also, that issue will happen for every class that is instrumented by this agentRemoving the
if
condition seems the only thing required here as: