Skip to content

[native-image] Error when compiling projects with Kotlin Coroutines #783

Closed

Description

@sdeleuze

When compiling a Spring Fu application that is using Kotlin Coroutines 1.0.0, I get the following error while the same application with Reactive only API compiles correctly.

fatal error: com.oracle.svm.core.util.VMError$HostedError: Non-instantiated type referenced by a compiled method: kotlin.Result$Companion
	at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:66)
	at com.oracle.svm.hosted.image.NativeImageCodeCache.addConstantToHeap(NativeImageCodeCache.java:366)
	at com.oracle.svm.hosted.image.NativeImageCodeCache.addConstantsToHeap(NativeImageCodeCache.java:350)
	at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:887)
	at com.oracle.svm.hosted.NativeImageGenerator.lambda$run$0(NativeImageGenerator.java:402)
	at java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1386)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Error: Processing image build request failed

Activity

  1. sdeleuze commented on Nov 7, 2018

    @sdeleuze
    CollaboratorAuthor
  2. zarechenskiy commented on Nov 16, 2018

    @zarechenskiy

    I'd love to show a minimized version of the issue:

    // kotlin 1.3.11
    suspend fun main() {
        foo()
    }
    
    suspend fun foo() {}
    

    Note that if you place Result.toString or Result.Companion.toString() (which is the same) at the beginning of the main function, then the error will be gone:

    // kotlin 1.3.11
    suspend fun main() {
        Result.toString()
        foo()
    }
    
    suspend fun foo() {}
    

    There are several references to kotlin/Result$Failure in the generated bytecode, which doesn't seem illegal (at least from the first glance).
    Maybe you could provide more information why this error appears? Could it be a bug in GraalVM?

  3. cstancu commented on Feb 11, 2019

    @cstancu
    Member

    @sdeleuze thanks for the report! @zarechenskiy thanks for the minimal reproducer! The issue is fixed in 57199de.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions