-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Function containing atomic operations should be private #4041
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
Function containing atomic operations should be private #4041
Conversation
Just to clarify: this fixes problem during K/N incremental compilation where compilation is done per-file and it is unsupported to have cross-file field accesses, which are generated by atomicfu plugin/volatile intrinsics lowering. |
… results in the failure of Native incremental compilation. Made BufferedChannel#sendImpl function private. This is a WA for KT-65554
2ff5e4e
to
be39731
Compare
@@ -1587,7 +1608,7 @@ internal open class BufferedChannel<E>( | |||
* It is nulled-out on both completion and cancellation paths that | |||
* could happen concurrently. | |||
*/ | |||
@BenignDataRace | |||
//@BenignDataRace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What did this poor thing do to deserve being commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, I did not mean it)
What are we trying to achieve with this PR? The problem only arises with |
@homuroll Am I right that if incremental compilation is not enabled for |
And is there a reason, why we can not enable K/N incremental compilation now? |
Generally, we are trying to avoid having incorrect IR in kotlinx.coroutines klibs. See KT-65554 for more details.
Yes, but an important thing to note is that the problem might arise in any project (with the flag enabled) depending on kotlinx.coroutines. In other words, this PR might improve Native incremental compilation stability for many users.
Well, this PR is simply a prerequisite for enabling Native incremental compilation in kotlinx.coroutines. After merging it, you can try to turn the flag on locally and see if it works for you.
Not quite, please see above.
You can try, but please note its status. That said, I think that trying it out in kotlinx.coroutines is a good idea. |
@SvyatoslavScherbina to sum it up: there is a bug somewhere between Kotlin/Native and atomicfu, but because fixing that bug could take a long time, as a quick workaround, we should merge this pull request so that the end users are less likely to be affected by it. Did I get this right? If so, just how critical is this bug? We'd like to publish a release today. Should we try to make it a last-minute addition?
Is this link correct? I only see information about incremental compilation failing and a description of how this PR would fix the failure. |
I would say that the bug is in atomicfu compiler plugin, since it generates incorrect IR. Everything else is true.
Not critical, but it hinders Kotlin/Native incremental compilation adoption.
It would be nice, but not absolutely necessary.
Yes, the link is correct. As I said, it provides more details about how this IR is incorrect (field access from another file), what causes it (atomicfu compiler plugin), how to reproduce this with a user-visible effect and how it affects K/N in practice. |
Got it, thanks. We already published a new release and didn't plan another one soon, so we can probably wait for this to be fixed on the side of atomicfu, or revisit this before the next release if the fix is not available by then. @mvicsokolova, WDYT? |
I think, we should merge this commit now, as this issue may cause problems while compiling a project that depends on kotlinx.coroutines and uses incremental compilation. I'll fix this cross-file access to the field in the atomicfu compiler plugin. And as soon, as we update to the corresponding Kotlin version, we'll be able to revert this WA. |
Could you then please drop a comment above |
The issue was caused by the call of an inline function, which invokes atomic operations, outside of the parent class. Seems like there no more cases like that left. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change seems safe: all the symbols are resolved to the same entities.
…otlin#4041) Calling a function containing atomic operations from a different file results in the failure of Native incremental compilation. Made BufferedChannel#sendImpl function private. This is a WA for KT-65554
Calling a function containing atomic operations from a different file results in the failure of Native incremental compilation.
Made
BufferedChannel#sendImpl
function private.This is a WA for KT-65554
Maybe we could refactor this in a better way though.