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

IllegalStateException: No minusAssign function found in minusAssign for IR transformation #274

Closed
e5l opened this issue Feb 9, 2023 · 5 comments
Assignees

Comments

@e5l
Copy link
Member

e5l commented Feb 9, 2023

Kotlin: 1.8.10
Atomicfu: 1.9.0 with IR transformation enabled

e: java.lang.IllegalStateException: No minusAssign function found in minusAssign
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicSymbols.getAtomicHandlerFunctionSymbol(AtomicSymbols.kt:483)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuIrBuilder.callFieldUpdater(AtomicfuIrBuilder.kt:79)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitCall(AtomicfuJvmIrTransformer.kt:549)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitCall(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlin.ir.expressions.IrCall.accept(IrCall.kt:25)
        at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:28)
        at org.jetbrains.kotlin.ir.expressions.IrExpression.transform(IrExpression.kt:21)
        at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
        at org.jetbrains.kotlin.ir.expressions.IrBlockBody.transformChildren(IrBlockBody.kt:31)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitBody(IrElementTransformer.kt:178)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitBody(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitBody(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitBlockBody(IrElementTransformer.kt:185)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitBlockBody(AtomicfuJvmIrTransformer.kt:638)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitBlockBody(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlin.ir.expressions.IrBlockBody.accept(IrBlockBody.kt:24)
        at org.jetbrains.kotlin.ir.expressions.IrBody.transform(IrBody.kt:21)
        at org.jetbrains.kotlin.ir.declarations.IrFunction.transformChildren(IrFunction.kt:61)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitDeclaration(IrElementTransformer.kt:103)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitDeclaration(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitDeclaration(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitFunction(IrElementTransformer.kt:120)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitFunction(AtomicfuJvmIrTransformer.kt:477)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitFunction(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitSimpleFunction(IrElementTransformer.kt:150)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitSimpleFunction(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitSimpleFunction(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlin.ir.declarations.IrSimpleFunction.accept(IrSimpleFunction.kt:36)
        at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:24)
        at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
        at org.jetbrains.kotlin.ir.declarations.IrClass.transformChildren(IrClass.kt:74)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitDeclaration(IrElementTransformer.kt:103)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitDeclaration(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitDeclaration(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitClass(IrElementTransformer.kt:110)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitClass(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitClass(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlin.ir.declarations.IrClass.accept(IrClass.kt:64)
        at org.jetbrains.kotlin.ir.IrElementBase.transform(IrElementBase.kt:24)
        at org.jetbrains.kotlin.ir.util.TransformKt.transformInPlace(transform.kt:35)
        at org.jetbrains.kotlin.ir.declarations.IrFile.transformChildren(IrFile.kt:40)
        at org.jetbrains.kotlin.ir.visitors.IrElementTransformer$DefaultImpls.visitFile(IrElementTransformer.kt:168)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitFile(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$AtomicfuTransformer.visitFile(AtomicfuJvmIrTransformer.kt:475)
        at org.jetbrains.kotlin.ir.declarations.IrFile.accept(IrFile.kt:30)
        at org.jetbrains.kotlin.ir.declarations.IrFile.transform(IrFile.kt:33)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer.transformAtomicfuDeclarations(AtomicfuJvmIrTransformer.kt:84)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer.transform(AtomicfuJvmIrTransformer.kt:64)
        at org.jetbrains.kotlinx.atomicfu.compiler.extensions.AtomicfuLoweringExtension.generate(AtomicfuLoweringExtension.kt:32)
        at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$lambda$1(JvmIrCodegenFactory.kt:186)
        at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:104)
        at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:218)
        at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:55)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.convertToIr(KotlinToJVMBytecodeCompiler.kt:225)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:102)
        at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:47)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:167)
        at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:53)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:101)
        at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:47)
        at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:485)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.runCompiler(IncrementalJvmCompilerRunner.kt:131)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.doCompile(IncrementalCompilerRunner.kt:424)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileImpl(IncrementalCompilerRunner.kt:360)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compileNonIncrementally(IncrementalCompilerRunner.kt:242)
        at org.jetbrains.kotlin.incremental.IncrementalCompilerRunner.compile(IncrementalCompilerRunner.kt:98)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.execIncrementalCompiler(CompileServiceImpl.kt:625)
        at org.jetbrains.kotlin.daemon.CompileServiceImplBase.access$execIncrementalCompiler(CompileServiceImpl.kt:101)
        at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1746)
        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 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:829)
@mvicsokolova mvicsokolova self-assigned this Feb 9, 2023
@e5l
Copy link
Member Author

e5l commented Jun 23, 2023

Any updates? Doesn't work with the new version as well

@e5l
Copy link
Member Author

e5l commented Jun 28, 2023

It fails for Ktor main branch: https://github.com/ktorio/ktor after enabling IR transformations

@mvicsokolova
Copy link
Collaborator

Hi! There is a bunch of changes in the JVM IR on review for 1.9.20 now, and this failure should be fixed there.

I'll try to minimize the problem and find a WA.

@recursive-rat4
Copy link

I get a similar exception when try to use -=, but directly calling getAndAdd works.

Kotlin 1.9.22
Atomicfu 0.23.2

> Task :blacknet-kernel:compileKotlin FAILED
e: java.lang.IllegalStateException: No minusAssign function found in CLASS CLASS name:AtomicLongFieldUpdater modality:FINAL visibility:public superTypes:[]
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.common.AbstractAtomicSymbols.getAtomicHandlerFunctionSymbol(AbstractAtomicSymbols.kt:84)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.JvmAtomicfuIrBuilder.callFieldUpdater(JvmAtomicfuIrBuilder.kt:75)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.jvm.AtomicfuJvmIrTransformer$JvmAtomicFunctionCallTransformer.transformAtomicUpdateCallOnProperty(AtomicfuJvmIrTransformer.kt:164)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.common.AbstractAtomicfuTransformer$AtomicFunctionCallTransformer.visitCall(AbstractAtomicfuTransformer.kt:602)
        at org.jetbrains.kotlinx.atomicfu.compiler.backend.common.AbstractAtomicfuTransformer$AtomicFunctionCallTransformer.visitCall(AbstractAtomicfuTransformer.kt:550)
        at org.jetbrains.kotlin.ir.expressions.IrCall.accept(IrCall.kt:26)
...

@mvicsokolova
Copy link
Collaborator

This issue will be solved, when the compiler plugin supports minusAssign/plusAssign operators.
Here is the related issue to track: #414

For now, please use incrementAndGet()/decrementAndGet()/addAndGet(value) methods.

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

No branches or pull requests

3 participants