Skip to content

glommio aborts when spanwed local task in non-default task queue panics #689

@vlovich

Description

@vlovich

The following code correctly fails the unit test printing "assertion failed: false", the backtrace, and then the test is failed. If you uncomment the commented out task queue creation, the test fails due to an abort that kills the entire process with:

assertion failed: false
<backtrace>

thread 'tests::test' panicked at scoped-tls-1.0.1/src/lib.rs:168:9:
cannot access a scoped thread local variable without calling `set` first
<backtrace>

thread 'tests::test' panicked at glommio/src/task/utils.rs:35:13:
aborting the process
<backtrace>

thread 'tests::test' panicked at library/core/src/panicking.rs:233:5:
panic in a destructor during cleanup
thread caused non-unwinding panic. aborting.

Expected:
I don't believe there's any meaningful reason that we should end up without the TLS just because I picked a non-default task queue to spawn the task into.

Actual:
The TLS is missing which causes a panic to be generated dropping the future with the drop logic being called abort_on_panic.

Test:

    #[test]
    fn test() {
        let ex = glommio::LocalExecutorBuilder::new(glommio::Placement::Fixed(0))
            // .blocking_thread_pool_placement(blocking_thread_pool_placement)
            .make()
            .unwrap();
        ex.run(async move {
            let tq = glommio::executor().current_task_queue();
            // let tq = glommio::executor().create_task_queue(
            //     glommio::Shares::Static(10),
            //     glommio::Latency::NotImportant,
            //     "latency queue",
            // );
            let task1 = unsafe {
                glommio::spawn_scoped_local_into(
                    async move {
                        glommio::timer::sleep(Duration::from_millis(1)).await;
                        assert!(false);
                    },
                    tq,
                )
            }
            .unwrap();
            let task2 = unsafe {
                glommio::spawn_scoped_local_into(
                    async move {
                        glommio::timer::sleep(Duration::from_secs(10)).await;
                    },
                    tq,
                )
            }
            .unwrap();
            futures_util::join!(task1, task2);
        });
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions