Skip to content
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

Do not use shaded version of byte buddy when real one is present in the classpath #1060

Closed
qwwdfsad opened this issue Mar 27, 2019 · 8 comments

Comments

@qwwdfsad
Copy link
Member

qwwdfsad commented Mar 27, 2019

java.lang.IllegalStateException: Error during attachment using: kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound@38dee15 caused by java.lang.UnsatisfiedLinkError: Native Library /home/.../.sdkman/candidates/java/8.0.202-zulu/jre/lib/amd64/libattach.so already loaded in another classloader

@qwwdfsad
Copy link
Member Author

Note that reflective lookup is not the best option, probably we should first investigate whether it is possible to achieve with a regular Bute Buddy API

@elizarov
Copy link
Contributor

This also opens a can of worms with version compatibility.... I wonder if it is possible to "shade" native libraries, too?

@qwwdfsad
Copy link
Member Author

qwwdfsad commented Mar 27, 2019

I am not sure it could work. Take a closer look at the library: it is platform and JVM specific and is bundled with JDK. What should we shade in that case?

@elizarov
Copy link
Contributor

Uh. I see. That is really bad. It is not just "already loaded" it is already loaded in a different class-loader, and we we cannot get get hold on this class-loader, then we are out of luck completely....

@elizarov
Copy link
Contributor

elizarov commented Mar 27, 2019

Similar bytebuddy sharing conflict between mockk/mockito was solved by avoiding shading bytebuddy altogether: mockk/mockk#15

@qwwdfsad
Copy link
Member Author

Yes, I've seen that. But we cannot avoid shading, otherwise java -jar myApp.jar -javaagent:... won't work.

@xbao
Copy link

xbao commented Jun 3, 2019

Hello, I just ran into this issue trying to use kotlinx-coroutines-debug and mockk. I've resolved it for now by compiling the debug jar without the shaded ByteBuddy and including it in my project.

I imagine using kotlinx-coroutines-debug and a mocking library is a pretty common use case. Perhaps a different kotlinx-coroutines-debug artifact could be published with the unshaded ByteBuddy? Or the normal one could be unshaded, with a fatjar artifact with the shaded ByteBuddy for the -javaagent uses?

@qwwdfsad
Copy link
Member Author

raphw/byte-buddy#670

Let's wait for Rafael and act accordingly

dkhalanskyjb added a commit that referenced this issue Feb 6, 2020
This way, it can work even with BlockHound on JDK8, which also uses
ByteBuddy and thus was in conflict.

Kind of solves
#1060, but since
now the debugging routine depends on BlockHound, where, it seems,
the same problem was not fixed, the original cause for concern
probably still stands.
dkhalanskyjb added a commit that referenced this issue Feb 7, 2020
This way, it can work even with BlockHound on JDK8, which also uses
ByteBuddy and thus was in conflict.

Kind of solves
#1060, but since
now the debugging routine depends on BlockHound, where, it seems,
the same problem was not fixed, the original cause for concern
probably still stands.
dkhalanskyjb added a commit that referenced this issue Feb 18, 2020
This way, it can work even with BlockHound on JDK8, which also uses
ByteBuddy and thus was in conflict.

Kind of solves
#1060, but since
now the debugging routine depends on BlockHound, where, it seems,
the same problem was not fixed, the original cause for concern
probably still stands.
dkhalanskyjb added a commit that referenced this issue Mar 13, 2020
This way, it can work even with BlockHound on JDK8, which also uses
ByteBuddy and thus was in conflict.

Kind of solves
#1060, but since
now the debugging routine depends on BlockHound, where, it seems,
the same problem was not fixed, the original cause for concern
probably still stands.
dkhalanskyjb added a commit that referenced this issue Mar 27, 2020
This way, it can work even with BlockHound on JDK8, which also uses
ByteBuddy and thus was in conflict.

Kind of solves
#1060, but since
now the debugging routine depends on BlockHound, where, it seems,
the same problem was not fixed, the original cause for concern
probably still stands.
dkhalanskyjb added a commit that referenced this issue Apr 6, 2020
This way, it can work even with BlockHound on JDK8, which also uses
ByteBuddy and thus was in conflict.

Kind of solves
#1060, but since
now the debugging routine depends on BlockHound, where, it seems,
the same problem was not fixed, the original cause for concern
probably still stands.
qwwdfsad added a commit that referenced this issue Apr 6, 2020
* Integration with BlockHound
* Improve build configuration of integration tests
* publication-validator is renamed to integration-testing;
* Add an integration test for coroutine debugger java agent
* Use JNA-based attach mechanism for dynamic attach

Fixes #1821 
Fixes #1060

Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
Co-authored-by: Sergei Egorov <bsideup@gmail.com>
qwwdfsad added a commit that referenced this issue Apr 24, 2020
* Integration with BlockHound
* Improve build configuration of integration tests
* publication-validator is renamed to integration-testing;
* Add an integration test for coroutine debugger java agent
* Use JNA-based attach mechanism for dynamic attach

Fixes #1821 
Fixes #1060

Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
Co-authored-by: Sergei Egorov <bsideup@gmail.com>
recheej pushed a commit to recheej/kotlinx.coroutines that referenced this issue Dec 28, 2020
* Integration with BlockHound
* Improve build configuration of integration tests
* publication-validator is renamed to integration-testing;
* Add an integration test for coroutine debugger java agent
* Use JNA-based attach mechanism for dynamic attach

Fixes Kotlin#1821 
Fixes Kotlin#1060

Co-authored-by: Vsevolod Tolstopyatov <qwwdfsad@gmail.com>
Co-authored-by: Sergei Egorov <bsideup@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants