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

[FATAL] Yield coroutines while stack unwinding causes panic while panicking #70

Open
zonyitoo opened this issue Aug 26, 2018 · 2 comments

Comments

@zonyitoo
Copy link
Owner

Reproducible example:

extern crate coio;
extern crate env_logger;

use coio::Scheduler;

fn main() {
    env_logger::init();

    Scheduler::new()
        .run(|| {
            struct A;

            impl Drop for A {
                fn drop(&mut self) {
                    Scheduler::sched();
                }
            }

            let _a = A;

            panic!("PANICKED in coroutine");
        }).unwrap();
}

While the coroutine is unwinding, Drop of A will be called. Coroutine is yield in the drop() function. Coroutine is now suspended, which means that the currently thread is still in panicking status, but execution process is now be switched to another coroutine. If the other coroutine panic, too, then it will definitely cause panic while panicking!.

@zonyitoo zonyitoo added the bug label Aug 26, 2018
@zonyitoo
Copy link
Owner Author

cc @lhecker , this is the root cause.

@lhecker
Copy link
Collaborator

lhecker commented Aug 26, 2018

@zonyitoo Yup that's basically why we asked the Rust devs to reconsider and stop using TLS for panics in the stdlib back then when we worked on coio. Since they denied my PR and basically said that it's unlikely even for an RFC to change this behaviour I think this might be a dead end for the project. 😕 (Unless you fork the stdlib of course.)

@zonyitoo zonyitoo changed the title Yield coroutines while stack unwinding causes panic while panicking [FATAL] Yield coroutines while stack unwinding causes panic while panicking Aug 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants