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

Workround #3881 breaks non-local returns in 1.8.0-RC #3985

Closed
Amejonah1200 opened this issue Dec 12, 2023 · 4 comments
Closed

Workround #3881 breaks non-local returns in 1.8.0-RC #3985

Amejonah1200 opened this issue Dec 12, 2023 · 4 comments
Labels

Comments

@Amejonah1200
Copy link

Amejonah1200 commented Dec 12, 2023

I recently upgraded the lib of one of my apps from 1.7.3 to 1.8.0-RC. I saw that something wasn't working a day later in my Grafana. After some investigations and deductions, I figured out that this bump caused functions not being executed, something had to do with locks.

After some time, I very professionally (using lots of printlns) debugged the whole code related to that feature. I found the bug out:

fun test() {
  mutex.withLock {
    return
  }
}

This doesn't release the lock. Why? Because someone decided to remove finally of that damn thing in #3881 .

image
image
image

https://kotlinlang.org/docs/inline-functions.html this even shows how to make a lock function which works. This will break a lot of code which relies on of having a finally out there.

@CLOVIS-AI
Copy link
Contributor

Ouch, that's a pretty big oversight. I'll let the team chime in on this one, I have no idea how to fix this without bringing back the original bug.

@jakobkmar
Copy link

I have no idea how to fix this without bringing back the original bug.

Isn't the original compiler bug (KT-58685) fixed in Kotlin 1.9.30 (or at least 2.0.0)? I guess the workaround can be removed then?

@dkhalanskyjb
Copy link
Collaborator

Thank you for your immense professionalism! println FTW.

Also, thank you for making the RC process work as intended. Breakage is expected in RC, and the saddest thing is when we publish an RC, no one finds an issue, but after the release, all the production code is suddenly broken.

dkhalanskyjb added a commit that referenced this issue Dec 13, 2023
Also, ensure that the workaround for KT-58685 still works.
It turns out, it was enough to move the `return` a bit to fix the
issue.

Fixes #3985
@werner77
Copy link

Could this be fixed with:

val result = try {
   action().also { unlock(owner) }
   ...

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

No branches or pull requests

5 participants