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

Compiler crash on suspended recursive inner fuction #2067

Closed
d-r-q opened this issue May 28, 2020 · 1 comment
Closed

Compiler crash on suspended recursive inner fuction #2067

d-r-q opened this issue May 28, 2020 · 1 comment
Assignees

Comments

@d-r-q
Copy link

d-r-q commented May 28, 2020

Kotlin-jvm version: 1.4-M1
Os: linux

Minimal example: https://github.com/d-r-q/coroutines-crash-me-gradle

Error log

./gradlew build                                                                                                                                                                                                                                                                                                                                                (master|✔)
Picked up _JAVA_OPTIONS: -Xmx2048m
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details

> Task :compileKotlin FAILED
e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: wrong bytecode generated
  @Lorg/jetbrains/annotations/Nullable;() // invisible
    // annotable parameter count: 1 (visible)
    // annotable parameter count: 1 (invisible)
    @Lorg/jetbrains/annotations/NotNull;() // invisible, parameter 0
   L0
   L1
   L2
    LINENUMBER 3 L2
    NEW TestKt$cloneStorage$2
    DUP
    ALOAD 1
    ACONST_NULL
    INVOKESPECIAL TestKt$cloneStorage$2.<init> (LTestKt$cloneStorage$2;Lkotlin/coroutines/Continuation;)V
    ASTORE 1
   L3
   L4
    LINENUMBER 11 L4
    ALOAD 1
    CHECKCAST TestKt$cloneStorage$2
    ASTORE 3
    NOP
    ICONST_0
    ISTORE 2
   L5
    NEW java/util/HashMap
    DUP
    INVOKESPECIAL java/util/HashMap.<init> ()V
    NOP
    GOTO L6
   L7
   L8
   L6
    ASTORE 4
    ALOAD 3
    ALOAD 4
    CHECKCAST java/util/Map
   L9
    LINENUMBER 11 L9
    ASTORE 4
    ASTORE 3
    NOP
    ICONST_0
    ISTORE 2
   L10
    NEW java/util/HashMap
    DUP
    INVOKESPECIAL java/util/HashMap.<init> ()V
    NOP
    GOTO L11
   L12
   L13
   L11
    ASTORE 5
    ALOAD 3
    ALOAD 4
    ALOAD 5
    CHECKCAST java/util/Map
    ALOAD 0
   L14
    LINENUMBER 11 L14
    INVOKEVIRTUAL TestKt$cloneStorage$2.invoke (Ljava/util/Map;Ljava/util/Map;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
    DUP
    INVOKESTATIC kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED ()Ljava/lang/Object;
    IF_ACMPNE L15
    ARETURN
   L15
    POP
    NOP
   L16
    LINENUMBER 12 L16
    GETSTATIC kotlin/Unit.INSTANCE : Lkotlin/Unit;
    ARETURN
   L17
    LOCALVARIABLE $fun$copyNs$2 LTestKt$cloneStorage$2; L3 L17 1
    LOCALVARIABLE $completion Lkotlin/coroutines/Continuation; L0 L17 0
    MAXSTACK = 5
    MAXLOCALS = 6

File being compiled: (2,1) in /home/azhidkov/0my/Alive/NSU/DB/2019-20/20/projects/coroutines-crash-me-gradle/src/main/kotlin/Test.kt
The root cause org.jetbrains.kotlin.codegen.CompilationException was thrown at: org.jetbrains.kotlin.codegen.TransformationMethodVisitor.visitEnd(TransformationMethodVisitor.kt:92)
        at org.jetbrains.kotlin.codegen.FunctionCodegen.endVisit(FunctionCodegen.java:978)
        at org.jetbrains.kotlin.codegen.FunctionCodegen.generateMethodBody(FunctionCodegen.java:497)
        at org.jetbrains.kotlin.codegen.FunctionCodegen.generateMethod(FunctionCodegen.java:265)
        at org.jetbrains.kotlin.codegen.FunctionCodegen.generateMethod(FunctionCodegen.java:181)
        at org.jetbrains.kotlin.codegen.FunctionCodegen.gen(FunctionCodegen.java:152)
        at org.jetbrains.kotlin.codegen.MemberCodegen.genSimpleMember(MemberCodegen.java:195)
        at org.jetbrains.kotlin.codegen.PackagePartCodegen.generateBody(PackagePartCodegen.java:95)
        at org.jetbrains.kotlin.codegen.MemberCodegen.generate(MemberCodegen.java:127)
        at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generateFile(PackageCodegenImpl.java:145)
        at org.jetbrains.kotlin.codegen.PackageCodegenImpl.generate(PackageCodegenImpl.java:70)
        at org.jetbrains.kotlin.codegen.DefaultCodegenFactory.generatePackage(CodegenFactory.kt:88)
        at org.jetbrains.kotlin.codegen.DefaultCodegenFactory.generateModule(CodegenFactory.kt:67)
        at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:640)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:196)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:164)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:51)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:86)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:105)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:346)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:102)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileIncrementally(IncrementalCompilerRunner.kt:240)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.access$compileIncrementally(IncrementalCompilerRunner.kt:39)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner$compile$2.invoke(IncrementalCompilerRunner.kt:81)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:93)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:606)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:99)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1645)
        at jdk.internal.reflect.GeneratedMethodAccessor97.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
        at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't transform method node:
cloneStorage (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;:
  @Lorg/jetbrains/annotations/Nullable;() // invisible
    // annotable parameter count: 1 (visible)
    // annotable parameter count: 1 (invisible)
    @Lorg/jetbrains/annotations/NotNull;() // invisible, parameter 0
   L0
   L1
   L2
    LINENUMBER 3 L2
    NEW TestKt$cloneStorage$2
    DUP
    ALOAD 1
    ACONST_NULL
    INVOKESPECIAL TestKt$cloneStorage$2.<init> (LTestKt$cloneStorage$2;Lkotlin/coroutines/Continuation;)V
    ASTORE 1
   L3
   L4
    LINENUMBER 11 L4
    ALOAD 1
    CHECKCAST TestKt$cloneStorage$2
    ASTORE 3
    NOP
    ICONST_0
    ISTORE 2
   L5
    NEW java/util/HashMap
    DUP
    INVOKESPECIAL java/util/HashMap.<init> ()V
    NOP
    GOTO L6
   L7
   L8
   L6
    ASTORE 4
    ALOAD 3
    ALOAD 4
    CHECKCAST java/util/Map
   L9
    LINENUMBER 11 L9
    ASTORE 4
    ASTORE 3
    NOP
    ICONST_0
    ISTORE 2
   L10
    NEW java/util/HashMap
    DUP
    INVOKESPECIAL java/util/HashMap.<init> ()V
    NOP
    GOTO L11
   L12
   L13
   L11
    ASTORE 5
    ALOAD 3
    ALOAD 4
    ALOAD 5
    CHECKCAST java/util/Map
    ALOAD 0
   L14
    LINENUMBER 11 L14
    INVOKEVIRTUAL TestKt$cloneStorage$2.invoke (Ljava/util/Map;Ljava/util/Map;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
    DUP
    INVOKESTATIC kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED ()Ljava/lang/Object;
    IF_ACMPNE L15
    ARETURN
   L15
    POP
    NOP
   L16
    LINENUMBER 12 L16
    GETSTATIC kotlin/Unit.INSTANCE : Lkotlin/Unit;
    ARETURN
   L17
    LOCALVARIABLE $fun$copyNs$2 LTestKt$cloneStorage$2; L3 L17 1
    LOCALVARIABLE $completion Lkotlin/coroutines/Continuation; L0 L17 0
    MAXSTACK = 5
    MAXLOCALS = 6

File is unknown
The root cause org.jetbrains.kotlin.codegen.CompilationException was thrown at: org.jetbrains.kotlin.codegen.TransformationMethodVisitor.visitEnd(TransformationMethodVisitor.kt:92)
        at org.jetbrains.kotlin.codegen.TransformationMethodVisitor.visitEnd(TransformationMethodVisitor.kt:92)
        at org.jetbrains.kotlin.codegen.FunctionCodegen.endVisit(FunctionCodegen.java:971)
        ... 44 more
Caused by: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't transform method node:
cloneStorage (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;:
  @Lorg/jetbrains/annotations/Nullable;() // invisible
    // annotable parameter count: 1 (visible)
    // annotable parameter count: 1 (invisible)
    @Lorg/jetbrains/annotations/NotNull;() // invisible, parameter 0
   L0
    LINENUMBER 3 L0
    NEW TestKt$cloneStorage$2
    DUP
    ALOAD 1
    ACONST_NULL
    INVOKESPECIAL TestKt$cloneStorage$2.<init> (LTestKt$cloneStorage$2;Lkotlin/coroutines/Continuation;)V
    ASTORE 1
   L1
    LINENUMBER 11 L1
    ALOAD 1
    CHECKCAST TestKt$cloneStorage$2
    ASTORE 3
    NOP
    ICONST_0
    ISTORE 2
   L2
    NEW java/util/HashMap
    DUP
    INVOKESPECIAL java/util/HashMap.<init> ()V
    NOP
    GOTO L3
   L3
    ASTORE 4
    ALOAD 3
    ALOAD 4
    CHECKCAST java/util/Map
   L4
    LINENUMBER 11 L4
    ASTORE 4
    ASTORE 3
    NOP
    ICONST_0
    ISTORE 2
   L5
    NEW java/util/HashMap
    DUP
    INVOKESPECIAL java/util/HashMap.<init> ()V
    NOP
    GOTO L6
   L6
    ASTORE 5
    ALOAD 3
    ALOAD 4
    ALOAD 5
    CHECKCAST java/util/Map
    ALOAD 0
   L7
    LINENUMBER 11 L7
    INVOKEVIRTUAL TestKt$cloneStorage$2.invoke (Ljava/util/Map;Ljava/util/Map;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
    DUP
    INVOKESTATIC kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED ()Ljava/lang/Object;
    IF_ACMPNE L8
    ARETURN
   L8
    POP
    NOP
   L9
    LINENUMBER 12 L9
    GETSTATIC kotlin/Unit.INSTANCE : Lkotlin/Unit;
    ARETURN
   L10
    LOCALVARIABLE $fun$copyNs$2 LTestKt$cloneStorage$2; L1 L10 1
    LOCALVARIABLE $completion Lkotlin/coroutines/Continuation; L0 L10 0
    MAXSTACK = 5
    MAXLOCALS = 6

File is unknown
The root cause java.lang.AssertionError was thrown at: org.jetbrains.kotlin.codegen.optimization.MethodVerifier.transform(MethodVerifier.kt:28)
        at org.jetbrains.kotlin.codegen.TransformationMethodVisitor.visitEnd(TransformationMethodVisitor.kt:92)
        at org.jetbrains.kotlin.codegen.TransformationMethodVisitor.visitEnd(TransformationMethodVisitor.kt:90)
        ... 45 more
Caused by: java.lang.AssertionError: AFTER mandatory stack transformations: incorrect bytecode
        at org.jetbrains.kotlin.codegen.optimization.MethodVerifier.transform(MethodVerifier.kt:28)
        at org.jetbrains.kotlin.codegen.optimization.transformer.CompositeMethodTransformer.transform(CompositeMethodTransformer.kt:25)
        at org.jetbrains.kotlin.codegen.optimization.OptimizationMethodVisitor.performTransformations(OptimizationMethodVisitor.kt:62)
        at org.jetbrains.kotlin.codegen.TransformationMethodVisitor.visitEnd(TransformationMethodVisitor.kt:70)
        ... 46 more
Caused by: java.lang.RuntimeException: org.jetbrains.org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 4: Expected an object reference, but found .
        at org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer.runAnalyzer(MethodTransformer.java:34)
        at org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer.analyze(MethodTransformer.java:44)
        at org.jetbrains.kotlin.codegen.optimization.MethodVerifier.transform(MethodVerifier.kt:26)
        ... 49 more
Caused by: org.jetbrains.org.objectweb.asm.tree.analysis.AnalyzerException: Error at instruction 4: Expected an object reference, but found .
        at org.jetbrains.org.objectweb.asm.tree.analysis.Analyzer.analyze(Analyzer.java:291)
        at org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer.runAnalyzer(MethodTransformer.java:31)
        ... 51 more
Caused by: org.jetbrains.org.objectweb.asm.tree.analysis.AnalyzerException: Expected an object reference, but found .
        at org.jetbrains.org.objectweb.asm.tree.analysis.BasicVerifier.copyOperation(BasicVerifier.java:90)
        at org.jetbrains.org.objectweb.asm.tree.analysis.BasicVerifier.copyOperation(BasicVerifier.java:43)
        at org.jetbrains.org.objectweb.asm.tree.analysis.Frame.execute(Frame.java:288)
        at org.jetbrains.org.objectweb.asm.tree.analysis.Analyzer.analyze(Analyzer.java:187)
        ... 52 more


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.1/userguide/command_line_interface.html#sec:command_line_warnings

BUILD FAILED in 5s
1 actionable task: 1 executed

@elizarov
Copy link
Contributor

elizarov commented Jun 1, 2020

Thanks. I've submitted bug to the Kotlin compiler: https://youtrack.jetbrains.com/issue/KT-39285

@elizarov elizarov closed this as completed Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants