Hi there! I am getting an Internal Compiler Error,...
# javascript
p
Hi there! I am getting an Internal Compiler Error, on Kotlin 1.6.21 trying to run javascript tests:
Copy code
> Task :core:compileTestDevelopmentExecutableKotlinJs FAILED
e: java.lang.NullPointerException
        at org.jetbrains.kotlin.ir.backend.js.ic.InvalidationKt.actualizeCacheForModule(invalidation.kt:444)
        at org.jetbrains.kotlin.cli.js.K2JsIrCompiler.doExecute(K2JsIrCompiler.kt:220)
        at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:178)
        at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:71)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:91)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:43)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:93)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1623)
        at sun.reflect.GeneratedMethodAccessor82.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:357)
        at sun.rmi.transport.Transport$1.run(Transport.java:200)
        at sun.rmi.transport.Transport$1.run(Transport.java:197)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:573)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:834)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:688)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:687)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
It worked and suddenly stopped working. We are also not doing anything fancy here. Just a normal gradle.build configuration. I see that the NPE is thrown here in `invalidation.kt:444`:
I would really like to know what is inside the variable
libraries
and
lib.toCannonicalPath()
! I was able to attach a debugger to gradle process, but my breakpoints are ignored in IntelliJ. So what could I do to find out what is wrong here?
c
pull out
libraries[lib.toCanonicalPath()]
into a variable and print it out when null (avoid the
!!
as that is causing your NPE)
p
I only have the binary of kotlin-compiler.embeddable.jar ...
I really do not want to try to build this thing ...
c
if you have access to
isCacheMap
you could list out all the libs (their canonical path) and (somehow) confirm those align with that is in the libraries map.
p
Right ... the thing is that I do not know how to attach the debugger to the gradle daemon, so that the IDE+debugger would also know about the kotlin sources. I set the breakpoints in the kotlin sources but the debugger process seems not to be aware of this.
c
There a section here on attaching a debugger, though this could perhaps be as simple as adding a few println statements.
p
I cannot add println statements. The NPE is happening in the kotlin compiler. It is an internal compiler error...
Ok, i can now debug the compiler. The trick was to set
Copy code
kotlin.compiler.execution.strategy=in-process
and then run
Copy code
./gradlew check -Dorg.gradle.debug=true
This will wait for the debugger to attach on Port 5005
👍 1
Ok here is the deal: I have an external dependency that brings in
kotlinx-coroutines-core.1.6.1
And my lib pulls
kotlinx-coroutines-core.1.6.0
Somehow the compiler does not remove the smaller version from the
icCacheMap
which some steps later results in the NPE.
After updating my dep to
kotlinx-coroutines-core.1.6.1
the errors is gone.
So in short: It is a problem in the dependency resolution in the kotlin compiler