Skip to content

Commit ef50709

Browse files
committed
[Test] Reproduce compiler crash with Jvm annotation and multiple backend threads
KT-78363 (cherry picked from commit 1eab93e)
1 parent 1ecd1d7 commit ef50709

File tree

5 files changed

+176
-0
lines changed

5 files changed

+176
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
$TESTDATA_DIR$/multipleBackendThreads.kt
2+
$TESTDATA_DIR$/multipleBackendThreads2.kt
3+
-d
4+
$TEMP_DIR$
5+
-Xbackend-threads=2
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// ISSUE: KT-78363
2+
class C1 @JvmOverloads constructor(val i: Int = 42, val s: String)
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
exception: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Exception while generating code for:
2+
CONSTRUCTOR visibility:public returnType:<root>.C1 [primary]
3+
VALUE_PARAMETER kind:Regular name:i index:0 type:kotlin.Int
4+
EXPRESSION_BODY
5+
ERROR_EXPR 'Default Stub' type=kotlin.Int
6+
VALUE_PARAMETER kind:Regular name:s index:1 type:kotlin.String
7+
annotations:
8+
JvmOverloads
9+
BLOCK_BODY
10+
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
11+
BLOCK type=kotlin.Unit origin=null
12+
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
13+
receiver: GET_VAR '<this>: <root>.C1 declared in <root>.C1' type=<root>.C1 origin=null
14+
value: GET_VAR 'i: kotlin.Int declared in <root>.C1.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
15+
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
16+
receiver: GET_VAR '<this>: <root>.C1 declared in <root>.C1' type=<root>.C1 origin=null
17+
value: GET_VAR 's: kotlin.String declared in <root>.C1.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER
18+
19+
at java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
20+
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1908)
21+
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.invokeCodegen(JvmIrCodegenFactory.kt:410)
22+
at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.runCodegen$cli(KotlinToJVMBytecodeCompiler.kt:414)
23+
at org.jetbrains.kotlin.cli.pipeline.jvm.JvmBackendPipelinePhase.executePhase(JvmBackendPipelinePhase.kt:89)
24+
at org.jetbrains.kotlin.cli.pipeline.jvm.JvmBackendPipelinePhase.executePhase(JvmBackendPipelinePhase.kt:27)
25+
at org.jetbrains.kotlin.cli.pipeline.PipelinePhase.phaseBody(PipelinePhase.kt:68)
26+
at org.jetbrains.kotlin.cli.pipeline.PipelinePhase.phaseBody(PipelinePhase.kt:58)
27+
at org.jetbrains.kotlin.config.phaser.NamedCompilerPhase.invoke(CompilerPhase.kt:102)
28+
at org.jetbrains.kotlin.backend.common.phaser.CompositePhase.invoke(PhaseBuilders.kt:22)
29+
at org.jetbrains.kotlin.config.phaser.CompilerPhaseKt.invokeToplevel(CompilerPhase.kt:53)
30+
at org.jetbrains.kotlin.cli.pipeline.AbstractCliPipeline.runPhasedPipeline(AbstractCliPipeline.kt:109)
31+
at org.jetbrains.kotlin.cli.pipeline.AbstractCliPipeline.execute(AbstractCliPipeline.kt:68)
32+
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecutePhased(K2JVMCompiler.kt:50)
33+
at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecutePhased(K2JVMCompiler.kt:41)
34+
at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:91)
35+
at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.kt:361)
36+
at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.kt:339)
37+
at org.jetbrains.kotlin.cli.common.CLICompiler.exec(CLICompiler.kt:303)
38+
at org.jetbrains.kotlin.cli.common.CLICompiler$Companion.doMainNoExit(CLICompiler.kt:440)
39+
at org.jetbrains.kotlin.cli.common.CLICompiler$Companion.doMainNoExit$default(CLICompiler.kt:435)
40+
at org.jetbrains.kotlin.test.CompilerTestUtil.executeCompiler(CompilerTestUtil.kt:38)
41+
at org.jetbrains.kotlin.cli.AbstractCliTest.executeCompilerGrabOutput(AbstractCliTest.java:71)
42+
at org.jetbrains.kotlin.cli.AbstractCliTest.executeCompilerGrabOutput(AbstractCliTest.java:53)
43+
at org.jetbrains.kotlin.cli.AbstractCliTest.doTest(AbstractCliTest.java:108)
44+
at org.jetbrains.kotlin.cli.AbstractCliTest.doJvmTest(AbstractCliTest.java:328)
45+
at org.jetbrains.kotlin.test.KotlinTestUtils.lambda$testWithCustomIgnoreDirective$7(KotlinTestUtils.java:554)
46+
at org.jetbrains.kotlin.test.KotlinTestUtils.lambda$runTestImpl$6(KotlinTestUtils.java:512)
47+
at org.jetbrains.kotlin.test.mutes.MuteWithDatabaseWrapperKt.wrapWithMuteInDatabase$lambda$2(muteWithDatabaseWrapper.kt:39)
48+
at org.jetbrains.kotlin.test.KotlinTestUtils.runTestImpl(KotlinTestUtils.java:520)
49+
at org.jetbrains.kotlin.test.KotlinTestUtils.runTest(KotlinTestUtils.java:464)
50+
at org.jetbrains.kotlin.cli.CliTestGenerated$Jvm.runTest(CliTestGenerated.java:1347)
51+
at org.jetbrains.kotlin.cli.CliTestGenerated$Jvm.testMultipleBackendThreads(CliTestGenerated.java:1741)
52+
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
53+
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
54+
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
55+
at java.lang.reflect.Method.invoke(Method.java:498)
56+
at junit.framework.TestCase.runTest(TestCase.java:177)
57+
at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.lambda$runTest$5(KtUsefulTestCase.java:265)
58+
at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.invokeTestRunnable(KtUsefulTestCase.java:292)
59+
at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.runTest(KtUsefulTestCase.java:280)
60+
at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.defaultRunBare(KtUsefulTestCase.java:303)
61+
at org.jetbrains.kotlin.test.testFramework.KtUsefulTestCase.runBare(KtUsefulTestCase.java:364)
62+
at junit.framework.TestResult$1.protect(TestResult.java:122)
63+
at junit.framework.TestResult.runProtected(TestResult.java:142)
64+
at junit.framework.TestResult.run(TestResult.java:125)
65+
at junit.framework.TestCase.run(TestCase.java:130)
66+
at junit.framework.TestSuite.runTest(TestSuite.java:241)
67+
at junit.framework.TestSuite.run(TestSuite.java:236)
68+
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
69+
at org.jetbrains.kotlin.test.JUnit3RunnerWithInnersForGradle.run(JUnit3RunnerWithInnersForGradle.java:71)
70+
at org.jetbrains.kotlin.test.JUnit3RunnerWithInners.run(JUnit3RunnerWithInners.java:54)
71+
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
72+
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
73+
at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:42)
74+
at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:80)
75+
at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:72)
76+
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:198)
77+
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:169)
78+
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:93)
79+
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:58)
80+
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:141)
81+
at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:57)
82+
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:103)
83+
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:85)
84+
at org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:47)
85+
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:124)
86+
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:99)
87+
at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:94)
88+
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63)
89+
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
90+
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
91+
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
92+
at java.lang.reflect.Method.invoke(Method.java:498)
93+
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
94+
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
95+
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
96+
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:92)
97+
at com.sun.proxy.$Proxy20.stop(Unknown Source)
98+
at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:200)
99+
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:132)
100+
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:103)
101+
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:63)
102+
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
103+
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:122)
104+
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:72)
105+
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
106+
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
107+
Caused by: java.lang.RuntimeException: Exception while generating code for:
108+
CONSTRUCTOR visibility:public returnType:<root>.C1 [primary]
109+
VALUE_PARAMETER kind:Regular name:i index:0 type:kotlin.Int
110+
EXPRESSION_BODY
111+
ERROR_EXPR 'Default Stub' type=kotlin.Int
112+
VALUE_PARAMETER kind:Regular name:s index:1 type:kotlin.String
113+
annotations:
114+
JvmOverloads
115+
BLOCK_BODY
116+
DELEGATING_CONSTRUCTOR_CALL 'public constructor <init> () [primary] declared in kotlin.Any'
117+
BLOCK type=kotlin.Unit origin=null
118+
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:i type:kotlin.Int visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
119+
receiver: GET_VAR '<this>: <root>.C1 declared in <root>.C1' type=<root>.C1 origin=null
120+
value: GET_VAR 'i: kotlin.Int declared in <root>.C1.<init>' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER
121+
SET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:s type:kotlin.String visibility:private [final]' type=kotlin.Unit origin=INITIALIZE_FIELD
122+
receiver: GET_VAR '<this>: <root>.C1 declared in <root>.C1' type=<root>.C1 origin=null
123+
value: GET_VAR 's: kotlin.String declared in <root>.C1.<init>' type=kotlin.String origin=INITIALIZE_PROPERTY_FROM_PARAMETER
124+
125+
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:58)
126+
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate$default(FunctionCodegen.kt:51)
127+
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethodNode(ClassCodegen.kt:429)
128+
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generateMethod(ClassCodegen.kt:446)
129+
at org.jetbrains.kotlin.backend.jvm.codegen.ClassCodegen.generate(ClassCodegen.kt:169)
130+
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateFile(JvmIrCodegenFactory.kt:446)
131+
at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.invokeCodegen$lambda$0$0(JvmIrCodegenFactory.kt:405)
132+
at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1640)
133+
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
134+
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
135+
at java.lang.Thread.run(Thread.java:750)
136+
Caused by: java.lang.IllegalStateException: should not be called
137+
at org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt.shouldNotBeCalled(addToStdlib.kt:330)
138+
at org.jetbrains.kotlin.utils.addToStdlib.AddToStdlibKt.shouldNotBeCalled$default(addToStdlib.kt:329)
139+
at org.jetbrains.kotlin.fir.FirBinaryDependenciesModuleData.getPlatform(FirModuleData.kt:132)
140+
at org.jetbrains.kotlin.fir.utils.exceptions.FirExceptionUtilsKt.withModuleDataEntry$lambda$0(firExceptionUtils.kt:63)
141+
at org.jetbrains.kotlin.utils.exceptions.ExceptionAttachmentBuilder.withEntry$lambda$0(ExceptionAttachmentBuilder.kt:22)
142+
at org.jetbrains.kotlin.utils.exceptions.ExceptionAttachmentBuilder.withEntry(ExceptionAttachmentBuilder.kt:38)
143+
at org.jetbrains.kotlin.utils.exceptions.ExceptionAttachmentBuilder.withEntry(ExceptionAttachmentBuilder.kt:18)
144+
at org.jetbrains.kotlin.fir.utils.exceptions.FirExceptionUtilsKt.withModuleDataEntry(firExceptionUtils.kt:60)
145+
at org.jetbrains.kotlin.fir.utils.exceptions.FirExceptionUtilsKt.withFirEntry(firExceptionUtils.kt:32)
146+
at org.jetbrains.kotlin.fir.backend.generators.Fir2IrCallableDeclarationsGenerator.createIrConstructor(Fir2IrCallableDeclarationsGenerator.kt:1169)
147+
at org.jetbrains.kotlin.fir.backend.Fir2IrDeclarationStorage.getIrConstructorSymbol(Fir2IrDeclarationStorage.kt:519)
148+
at org.jetbrains.kotlin.fir.backend.Fir2IrDeclarationStorage.getIrConstructorSymbol$default(Fir2IrDeclarationStorage.kt:510)
149+
at org.jetbrains.kotlin.fir.backend.generators.CallAndReferenceGenerator.convertToIrConstructorCall(CallAndReferenceGenerator.kt:937)
150+
at org.jetbrains.kotlin.fir.lazy.AbstractFir2IrLazyDeclaration.createLazyAnnotations$lambda$0(AbstractFir2IrLazyDeclaration.kt:42)
151+
at org.jetbrains.kotlin.ir.declarations.lazy.SynchronizedLazyVar.getValue(lazyUtil.kt:29)
152+
at org.jetbrains.kotlin.ir.declarations.lazy.SynchronizedLazyVar.getValue(lazyUtil.kt:40)
153+
at org.jetbrains.kotlin.fir.lazy.Fir2IrLazyClass.getAnnotations(Fir2IrLazyClass.kt:62)
154+
at org.jetbrains.kotlin.ir.util.IrUtilsKt.getAnnotation(IrUtils.kt:333)
155+
at org.jetbrains.kotlin.ir.util.AdditionalIrUtilsKt.getAnnotationTargets(AdditionalIrUtils.kt:340)
156+
at org.jetbrains.kotlin.backend.jvm.codegen.AnnotationCodegen.genAnnotations(AnnotationCodegen.kt:60)
157+
at org.jetbrains.kotlin.backend.jvm.codegen.AnnotationCodegen.genAnnotations$default(AnnotationCodegen.kt:58)
158+
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.doGenerate(FunctionCodegen.kt:96)
159+
at org.jetbrains.kotlin.backend.jvm.codegen.FunctionCodegen.generate(FunctionCodegen.kt:55)
160+
... 10 more
161+
162+
INTERNAL_ERROR
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// ISSUE: KT-78363
2+
class C2 @JvmOverloads constructor(val i: Int, val s: String = "default")

compiler/tests-integration/tests-gen/org/jetbrains/kotlin/cli/CliTestGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)