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

Conditions: document that conditions can only be handled in the same task #9001

Closed
catamorphism opened this issue Sep 5, 2013 · 7 comments
Closed
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@catamorphism
Copy link
Contributor

If task A spawns task B, and B has an unhandled condition, that manifests as task B failing -- any handlers in A won't get invoked. This was pretty sensible once I thought about it, but it surprised me at first. I think the conditions tutorial should mention it.

@catamorphism
Copy link
Contributor Author

I'm wondering if this is a good thing, actually. Suppose I want to spawn a task, and execute some code that might raise condition A, B or C. Whereas in the single-threaded case, I would be able to do:

A.trap(a_handler, B.trap(b_handler, C.trap(do_work())))

and know that my handlers would trap all the conditions, if do_work spawns tasks internally, and if the work done inside the tasks would raise conditions, then the handlers don't suffice and rather, inside do_work, I have to repeatedly check for task failure, decide whether the task failure was because of a condition, and then re-raise a condition of necessary. It seems kind of like an abstraction violation that I have to know whether or not do_work spawns any tasks to know, in the above code, whether I could possibly get an uncaught A, B or C condition.

Maybe I'm just trying to use conditions for something they shouldn't be used for, though.

@nikomatsakis
Copy link
Contributor

This is an interesting point. I do think that this is how conditions
should work, but it's an unfortunate interaction. I feel like there
is potentially a need for three kinds of parallel "processes":

  • Tasks as we know them today. Memory independent actors that run
    asynchronously from one another.
  • "Synchronous" tasks for containing failure. Memory independent but
    their lifetimes are linked to the parent. In other words, you don't
    just spawn them and let them run, but rather spawn them and they
    are implicitly joined.
  • Parallel jobs. These may share memory and are intended to divide
    up parallel work, like processing every element of an array in
    parallel. Because the memory spaces are linked, failure in a job
    propagates to its parent.

Conditions in the parent would be in scope for the latter two, but
not the first one.

@mstewartgallus
Copy link
Contributor

This sort of relates to how RWArc variables can be poisoned by write actions failing, or how Java's FutureTasks can be poisoned. Maybe if there was some-way to register the condition before failure, and then reinvoke the task if appropriate? So far, I'm thinking of something along the lines of future.recv(|c| c.reinvoke(0)) // Provide a default value of 0 in case we have an exceptional condition. This exact interface is problematic though because than tasks could be left as garbage waiting to know if they should fail, or not.

@owaspjocur
Copy link

@catamorphism This fix is actually updating the conditions tutorial? or after reading the reactions, there are some issues regarding how conditions and tasks interact. Let me know in which direction this issue is going

@pnkfelix
Copy link
Member

part of #11755

@pongad
Copy link
Contributor

pongad commented Mar 29, 2014

Delete issue because conditions are removed?

@alexcrichton
Copy link
Member

Indeed, thanks @pongad!

flip1995 pushed a commit to flip1995/rust that referenced this issue Jun 16, 2022
Fix false positive for `never_loop` struct expression fields

Fixes rust-lang#9001.

changelog: [`never_loop`]: Now checks for `continue` in struct expression
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

7 participants