-
Notifications
You must be signed in to change notification settings - Fork 1.9k
runBlocking
executes other tasks instead of its own
#4215
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
Comments
(Excerpts from our design meeting with One solution to this is to have The problem is that In any case, prioritizing own work has a downside: the following code will stop working: runBlocking {
var exit = false
launch {
runBlocking {
while (!exit) yield()
}
}
launch {
exit = true
}
} The inner In summary, if this issue is actually bothering someone, we know how to fix it, but if it doesn't, we'd prefer not to change |
I still think this is the main problem. |
Great analogy 👌 |
👀 |
Describe the bug
A guy promises to an old lady that he'll fix a broken staircase, but then arrives to the house and notices that it's in complete disrepair. He calls his old friend to come and redo the circuitry. He doesn't touch the instruments: "My friend will need them, and after he's done, then I'll fix the staircase." The friend arrives and notices that the house is in complete disrepair. He calls another guy to come and fix a door that's hanging on one hinge. Meanwhile, he doesn't touch the instruments: "Let my friend fix the door first, and then I'll do my job". Repeat this situation enough times, and you get hundreds of people in one room, with no one doing anything. Repeat this more, and the house blows up because of how many people are squeezed in there.
These guys were
runBlocking
. The house is the stack space, and the set of tools is the current thread. The old lady is an unfortunate user of our code.Reported in https://youtrack.jetbrains.com/issue/KT-66219.
Related to #3982: if we fix this, the reproducer for #3982 will no longer work, though the general issue will likely still be there. EDIT: yes, it will.
Provide a Reproducer
prints
The text was updated successfully, but these errors were encountered: