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

Coroutines-debug JUnit rules crashes on Apple Silicon due to wrong architecture #3001

Closed
hfhbd opened this issue Oct 25, 2021 · 5 comments
Closed
Labels

Comments

@hfhbd
Copy link
Contributor

hfhbd commented Oct 25, 2021

Hey,
I want to build Ktor on Apple Silicon. The tests use coroutines debug JUnit rules. This dependency uses byte buddy, which tries to execute an Intel native framework, which fails due to wrong architecture:

Caused by: java.lang.UnsatisfiedLinkError: /Users/philipwedemann/Library/Caches/JNA/temp/jna1105677674605096590.tmp: dlopen(/Users/philipwedemann/Library/Caches/JNA/temp/jna1105677674605096590.tmp, 0x0001): tried: '/Users/philipwedemann/Library/Caches/JNA/temp/jna1105677674605096590.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64e')), '/usr/lib/jna1105677674605096590.tmp' (no such file)
Error during attachment using: INSTANCE
java.lang.IllegalStateException: Error during attachment using: INSTANCE
	at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:613)
	at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:586)
	at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:538)
	at kotlinx.coroutines.debug.internal.ByteBuddyDynamicAttach.attach(Attach.kt:21)
	at kotlinx.coroutines.debug.internal.ByteBuddyDynamicAttach.invoke(Attach.kt:17)
	at kotlinx.coroutines.debug.internal.ByteBuddyDynamicAttach.invoke(Attach.kt:15)
	at kotlinx.coroutines.debug.internal.DebugProbesImpl.install(DebugProbesImpl.kt:86)
	at kotlinx.coroutines.debug.DebugProbes.install(DebugProbes.kt:72)
	at kotlinx.coroutines.debug.junit4.CoroutinesTimeout.<init>(CoroutinesTimeout.kt:59)
	at kotlinx.coroutines.debug.junit4.CoroutinesTimeout$Companion.seconds(CoroutinesTimeout.kt:83)
	at kotlinx.coroutines.debug.junit4.CoroutinesTimeout$Companion.seconds(CoroutinesTimeout.kt:72)
	at kotlinx.coroutines.debug.junit4.CoroutinesTimeout$Companion.seconds$default(CoroutinesTimeout.kt:67)
	at io.ktor.client.engine.cio.ConnectErrorsTest.<init>(ConnectErrorsTest.kt:31)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:250)
	at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:260)
	at org.junit.runners.BlockJUnit4ClassRunner$2.runReflectiveCall(BlockJUnit4ClassRunner.java:309)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:306)
	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:121)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at kotlinx.coroutines.repackaged.net.bytebuddy.agent.Attacher.install(Attacher.java:106)
	at kotlinx.coroutines.repackaged.net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:608)
	... 62 more
Caused by: java.lang.UnsatisfiedLinkError: /Users/philipwedemann/Library/Caches/JNA/temp/jna1105677674605096590.tmp: dlopen(/Users/philipwedemann/Library/Caches/JNA/temp/jna1105677674605096590.tmp, 0x0001): tried: '/Users/philipwedemann/Library/Caches/JNA/temp/jna1105677674605096590.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64e')), '/usr/lib/jna1105677674605096590.tmp' (no such file)
	at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
	at java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2442)
	at java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2498)
	at java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2694)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2627)
	at java.base/java.lang.Runtime.load0(Runtime.java:768)
	at java.base/java.lang.System.load(System.java:1837)
	at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1018)
	at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:988)
	at com.sun.jna.Native.<clinit>(Native.java:195)
	at kotlinx.coroutines.repackaged.net.bytebuddy.agent.VirtualMachine$ForHotSpot$Connection$ForJnaPosixSocket$Factory.withDefaultTemporaryFolder(VirtualMachine.java:893)
	at kotlinx.coroutines.repackaged.net.bytebuddy.agent.VirtualMachine$ForHotSpot.attach(VirtualMachine.java:243)
	... 68 more

Versions:
Kotlin: 1.5.31
Coroutines Debug: 1.5.2-mt
JDK: openjdk 11.0.13 2021-10-19 LTS
OpenJDK Runtime Environment Zulu11.52+13-CA (build 11.0.13+8-LTS)
OpenJDK 64-Bit Server VM Zulu11.52+13-CA (build 11.0.13+8-LTS, mixed mode)
macOS: macOS 12.0.1 (21A559)
Hardware: MacBook Air 10,1 with Apple M1

qwwdfsad added a commit that referenced this issue Oct 28, 2021
@qwwdfsad
Copy link
Member

JNA version has to be updated to at least 5.7.

You can add an explicit dependency to net.java.dev.jna:jna and net.java.dev.jna:jna-platform to your project in order to workaround the issue

@qwwdfsad qwwdfsad added the bug label Oct 28, 2021
qwwdfsad added a commit that referenced this issue Oct 28, 2021
@hfhbd
Copy link
Contributor Author

hfhbd commented Oct 29, 2021

Thank you for the workaround!

@mochadwi
Copy link

mochadwi commented Dec 2, 2021

does this means for android project we need to add the following?

testImplementation("net.java.dev.jna:jna:5.9")
testImplementation("net.java.dev.jna:jna-platform:5.9")

@hfhbd
Copy link
Contributor Author

hfhbd commented Dec 2, 2021

@mochadwi Only if you want to use kotlinx-coroutines-debug-jvm for testing code on macOS with an M1 processor (eg unit tests). On device tests are not affected.

yorickhenning pushed a commit to yorickhenning/kotlinx.coroutines that referenced this issue Jan 28, 2022
pablobaxter pushed a commit to pablobaxter/kotlinx.coroutines that referenced this issue Sep 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants