Skip to content

!Send Future violates stacked borrow rules #3796

Closed
@coder137

Description

@coder137

Tokio issue: tokio-rs/tokio#6750
Futures issue: rust-lang/futures-rs#2877

Explanation

The tests only fail when !Send future is used along with tokio::join! or futures::join!

Miri message

error: Undefined Behavior: trying to retag from <204081> for SharedReadWrite permission at alloc61855[0x88], but that tag does not exist in the borrow stack for this location
   --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.38.1/src/sync/mpsc/bounded.rs:242:22
    |
242 |         poll_fn(|cx| self.chan.recv(cx)).await
    |                      ^^^^^^^^^
    |                      |
    |                      trying to retag from <204081> for SharedReadWrite permission at alloc61855[0x88], but that tag does not exist in the borrow stack for this location
    |                      this error occurs as part of two-phase retag at alloc61855[0x88..0x90]
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <204081> was created by a Unique retag at offsets [0x88..0x90]
   --> tests/tokio_tests.rs:13:26
    |
13  |             let (a, b) = tokio::join!(rx1.recv(), rx2.recv());
    |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: <204081> was later invalidated at offsets [0x58..0xd8] by a SharedReadOnly retag
   --> /home/runner/work/ticked-async-executor/ticked-async-executor/src/ticked_async_executor.rs:[115](https://github.com/coder137/ticked-async-executor/actions/runs/10259175195/job/28383207204#step:8:116):17
    |
115 |                 runnable.run();
    |                 ^^^^^^^^^^^^^^

The relevant debug logs are in the individual issues linked above

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-supportCategory: Not necessarily a bug, but someone asking for support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions