CLOVIS
09/04/2023, 9:44 PMRobert Jaros
09/04/2023, 10:12 PMwithLock
function seems to work correctly, and (I think) should work exactly the same:
private suspend inline fun <T> withLock(block: () -> T): T {
lock()
val result = try {
block()
} catch (e: Throwable) {
unlock()
throw e
}
unlock()
return result
}
CLOVIS
09/05/2023, 7:54 AMArtem Kobzar
09/05/2023, 7:58 AMArtem Kobzar
09/05/2023, 7:58 AMCLOVIS
09/05/2023, 7:59 AMCLOVIS
09/05/2023, 8:02 AMCLOVIS
09/05/2023, 8:02 AMCLOVIS
09/05/2023, 7:43 PMRobert Jaros
09/05/2023, 7:47 PMCLOVIS
09/05/2023, 7:48 PMCLOVIS
09/05/2023, 7:49 PMCLOVIS
09/05/2023, 7:49 PMRobert Jaros
09/05/2023, 7:58 PMCLOVIS
09/05/2023, 8:02 PMRobert Jaros
09/05/2023, 8:03 PMCLOVIS
09/05/2023, 8:06 PMgit clone <https://gitlab.com/opensavvy/pedestal.git>
cd pedestal
git switch 101-lock-bug # β that's where I put your reproducer, you can stay on the 'main' branch if you want to see it for real
./gradlew state:jsNodeTest
Tests opensavvy.state.FailureEndToEndTest.usersCannotGetUnsharedCounters
and opensavvy.state.FailureEndToEndTest.usersCannotGetACounterThatDoesntExist
will fail because of the bug.CLOVIS
09/05/2023, 8:06 PMversions.properties
at the root of the repository (we're using #refreshversions)CLOVIS
09/05/2023, 8:09 PMmain
branch is going to change quite a bit very soon in order to use the version catalog, Kotlin 1.9.0 etc. AFAIK, it doesn't impact the problem.Robert Jaros
09/05/2023, 8:12 PMwithLock
to withLockHack
only in one call?Robert Jaros
09/05/2023, 8:13 PMFailureEndToEndTest.kt
the tests pass.CLOVIS
09/05/2023, 8:15 PMCLOVIS
09/05/2023, 8:15 PMCLOVIS
09/05/2023, 8:17 PMinline
? Is it the finally
?Robert Jaros
09/05/2023, 8:17 PMfinally
Robert Jaros
09/05/2023, 8:19 PMfinally
in Kotlin/JS earlier in some complex inline and suspending code. Unfortunately I've never managed to create a reproducer so I couldn't fill an issue.CLOVIS
09/05/2023, 8:20 PMRobert Jaros
09/05/2023, 8:21 PMwithLock
is from kotlinx-coroutines :)CLOVIS
09/05/2023, 8:22 PMRobert Jaros
09/05/2023, 8:23 PMCLOVIS
09/05/2023, 8:24 PMCLOVIS
09/05/2023, 8:27 PMCLOVIS
09/05/2023, 8:27 PMCLOVIS
09/05/2023, 8:28 PMRobert Jaros
09/05/2023, 8:28 PMRobert Jaros
09/05/2023, 8:29 PMCLOVIS
09/05/2023, 8:30 PMArtem Kobzar
09/06/2023, 9:18 AMmaster
and work on fix, that I hope, I will backport into 1.9.20
CLOVIS
09/06/2023, 12:09 PMCLOVIS
09/06/2023, 12:09 PMArtem Kobzar
09/06/2023, 12:14 PMinline
functions and finally
block inside of them.
The simplest workaround will be to remote inline
keyword from the withLock
function or to make some wrapper the function that will be a regular function (without inline
keyword).CLOVIS
09/06/2023, 1:49 PMinline
nor creating a wrapper, and the duplication is minimal, so I feel it may be easier to integrate into KotlinX.Coroutines? I doubt removing inline
would be accepted, since that's a binary-incompatible change.CLOVIS
09/06/2023, 9:38 PM