Skip to content

[dbsp] Use Cell in place of RefCell where we can.#5956

Merged
blp merged 2 commits intomainfrom
cell
Apr 3, 2026
Merged

[dbsp] Use Cell in place of RefCell where we can.#5956
blp merged 2 commits intomainfrom
cell

Conversation

@blp
Copy link
Copy Markdown
Member

@blp blp commented Mar 30, 2026

RefCell is relatively expensive because it maintains a borrow counter and associated lock-like logic. Cell is just a transparent wrapper around the inner type, so that it uses less time and space.

Describe Manual Test Plan

I ran the unit tests.

@blp blp requested a review from ryzhyk March 30, 2026 19:18
@blp blp self-assigned this Mar 30, 2026
@blp blp added DBSP core Related to the core DBSP library performance rust Pull requests that update Rust code labels Mar 30, 2026
Copy link
Copy Markdown

@mythical-fred mythical-fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@ryzhyk ryzhyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a no-brainer. Thank you!

@blp blp added this pull request to the merge queue Apr 1, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 2, 2026
@blp
Copy link
Copy Markdown
Member Author

blp commented Apr 2, 2026

The merge failed running the unit tests:

panicked at crates/dbsp/src/circuit/runtime.rs:972:64:
cannot access a task-local storage value without setting it first
thread panicked while processing panic. aborting.
Aborted (core dumped)

I was able to reproduce this locally with cargo test -p dbsp --lib and got the backtrace at the end of this comment. It only reproduces sometimes, it doesn't (quickly) reproduce with only a subset of tests, and it doesn't (quickly) reproduce without this PR. It also doesn't reproduce quickly with RUST_BACKTRACE=1. So, it seems to be very timing- and luck-dependent.

The issue appears to be related to merger threads and in particular the variables set up by scope_tokio_merger_locals:

fn scope_tokio_merger_locals<F>(
    worker_index: usize,
    buffer_cache: Arc<BufferCache>,
    slab_allocator: Arc<FBufSlabs>,
    future: F,
) -> impl Future<Output = F::Output>
where
    F: Future,
{
    TOKIO_WORKER_INDEX.scope(
        worker_index,
        TOKIO_BUFFER_CACHE.scope(buffer_cache, TOKIO_FBUF_SLABS.scope(slab_allocator, future)),
    )
}
#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0)
    at pthread_kill.c:44
#1  0x00007fbbcab8a493 in __pthread_kill_internal (threadid=<optimized out>, signo=6) at pthread_kill.c:89
#2  0x00007fbbcab3018e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007fbbcab176d0 in __GI_abort () at abort.c:77
#4  0x0000559165268dfa in std::sys::pal::unix::abort_internal () at library/std/src/sys/pal/unix/mod.rs:363
#5  0x0000559165276439 in std::process::abort () at library/std/src/process.rs:2535
#6  0x00005591652776ba in std::panicking::panic_with_hook () at library/std/src/rt.rs:44
#7  0x000055916527737a in std::panicking::panic_handler::{closure#0} () at library/std/src/panicking.rs:691
#8  0x00005591652713b9 in std::sys::backtrace::__rust_end_short_backtrace<std::panicking::panic_handler::{closure_env#0}, !> () at library/std/src/sys/backtrace.rs:176
#9  0x000055916525779d in std::panicking::panic_handler () at library/std/src/panicking.rs:689
#10 0x00005591652b6cac in core::panicking::panic_fmt () at library/core/src/panicking.rs:80
#11 0x00005591632d3048 in tokio::task::task_local::LocalKey<usize>::with<usize, tokio::task::task_local::{impl#1}::get::{closure_env#0}<usize>, usize> (self=0x5591654ef978 <dbsp::circuit::runtime::TOKIO_WORKER_INDEX>, 
    f=...)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/task/task_local.rs:236
#12 0x00005591632d2f41 in tokio::task::task_local::LocalKey<usize>::get<usize> (
    self=0x5591654ef978 <dbsp::circuit::runtime::TOKIO_WORKER_INDEX>)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/task/task_local.rs:276
#13 0x0000559163acd29e in dbsp::circuit::runtime::Runtime::worker_index ()
    at crates/dbsp/src/circuit/runtime.rs:972
#14 0x0000559163ace02d in dbsp::circuit::runtime::Runtime::local_worker_offset ()
    at crates/dbsp/src/circuit/runtime.rs:983
#15 0x0000559163ace4f3 in dbsp::circuit::runtime::Runtime::panic (self=0x7fb8bffff4e0, 
    panic_info=0x7fb8bfffca58) at crates/dbsp/src/circuit/runtime.rs:1259
#16 0x00005591628bcc88 in dbsp::circuit::runtime::panic_hook::{closure#0} (runtime=...)
    at crates/dbsp/src/circuit/runtime.rs:568
#17 0x0000559162d4f7e7 in std::thread::local::LocalKey<core::cell::RefCell<core::option::Option<dbsp::circuit::runtime::Runtime>>>::try_with<core::cell::RefCell<core::option::Option<dbsp::circuit::runtime::Runtime>>, dbsp::circuit::runtime::panic_hook::{closure_env#0}, ()> (self=0x5591654eff68, f=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:513
#18 0x0000559162d291c5 in std::thread::local::LocalKey<core::cell::RefCell<core::option::Option<dbsp::circuit::runtime::Runtime>>>::with<core::cell::RefCell<core::option::Option<dbsp::circuit::runtime::Runtime>>, dbsp::circuit::runtime::panic_hook::{closure_env#0}, ()> (self=0x5591654eff68, f=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:477
#19 0x0000559163ac5806 in dbsp::circuit::runtime::panic_hook (panic_info=0x7fb8bfffca58, 
    default_panic_hook=...) at crates/dbsp/src/circuit/runtime.rs:564
#20 0x00005591629f3e57 in dbsp::circuit::runtime::{impl#11}::run::{closure#0}<dbsp::circuit::dbsp_handle::{impl#11}::init_circuit::{closure_env#3}<fn(&mut dbsp::circuit::circuit_builder::ChildCircuit<(), ()>) -> core::result::Result<(dbsp::operator::input::IndexedZSetHandle<i32, i32>, dbsp::operator::output::OutputHandle<dbsp::typed_batch::TypedBatch<i32, i32, i64, dbsp::trace::spine_async::snapshot::SpineSnapshot<dbsp::trace::ord::fallback::indexed_wset::FallbackIndexedWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::data::Data, dyn dbsp::dyn--Type <RET> for more, q to quit, c to continue without paging--
amic::weight::WeightTyped<Type=i64>>>>>, dbsp::operator::output::OutputHandle<dbsp::typed_batch::TypedBatch<i32, i32, i64, dbsp::trace::spine_async::snapshot::SpineSnapshot<dbsp::trace::ord::fallback::indexed_wset::FallbackIndexedWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>>>), anyhow::Error>, (dbsp::operator::input::IndexedZSetHandle<i32, i32>, dbsp::operator::output::OutputHandle<dbsp::typed_batch::TypedBatch<i32, i32, i64, dbsp::trace::spine_async::snapshot::SpineSnapshot<dbsp::trace::ord::fallback::indexed_wset::FallbackIndexedWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>>>, dbsp::operator::output::OutputHandle<dbsp::typed_batch::TypedBatch<i32, i32, i64, dbsp::trace::spine_async::snapshot::SpineSnapshot<dbsp::trace::ord::fallback::indexed_wset::FallbackIndexedWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>>>), dbsp::circuit::dbsp_handle::CircuitConfig>, &dbsp::circuit::dbsp_handle::CircuitConfig> (panic_info=0x7fb8bfffca58) at crates/dbsp/src/circuit/runtime.rs:659
#21 0x00005591652775b2 in alloc::boxed::{impl#33}::call<(&std::panic::PanicHookInfo), (dyn core::ops::function::Fn<(&std::panic::PanicHookInfo), Output=()> + core::marker::Send + core::marker::Sync), alloc::alloc::Global>
    () at library/alloc/src/boxed.rs:2220
#22 std::panicking::panic_with_hook () at library/std/src/panicking.rs:833
#23 0x000055916527737a in std::panicking::panic_handler::{closure#0} () at library/std/src/panicking.rs:691
#24 0x00005591652713b9 in std::sys::backtrace::__rust_end_short_backtrace<std::panicking::panic_handler::{closure_env#0}, !> () at library/std/src/sys/backtrace.rs:176
#25 0x000055916525779d in std::panicking::panic_handler () at library/std/src/panicking.rs:689
#26 0x00005591652b6cac in core::panicking::panic_fmt () at library/core/src/panicking.rs:80
#27 0x00005591632d2fe5 in tokio::task::task_local::LocalKey<alloc::sync::Arc<dbsp::storage::buffer_cache::cache::BufferCache, alloc::alloc::Global>>::with<alloc::sync::Arc<dbsp::storage::buffer_cache::cache::BufferCache, alloc::alloc::Global>, tokio::task::task_local::{impl#1}::get::{closure_env#0}<alloc::sync::Arc<dbsp::storage::buffer_cache::cache::BufferCache, alloc::alloc::Global>>, alloc::sync::Arc<dbsp::storage::buffer_cache::cache::BufferCache, alloc::alloc::Global>> (self=0x5591654ef970 <dbsp::circuit::runtime::TOKIO_BUFFER_CACHE>, f=...)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/task/task_local.rs:236
#28 0x00005591632d2f21 in tokio::task::task_local::LocalKey<alloc::sync::Arc<dbsp::storage::buffer_cache::cache::BufferCache, alloc::alloc::Global>>::get<alloc::sync::Arc<dbsp::storage::buffer_cache::cache::BufferCache, alloc::alloc::Global>> (self=0x5591654ef970 <dbsp::circuit::runtime::TOKIO_BUFFER_CACHE>)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/task/task_local.rs:276
#29 0x0000559163accf97 in dbsp::circuit::runtime::Runtime::buffer_cache ()
    at crates/dbsp/src/circuit/runtime.rs:841
#30 0x000055915faf8d15 in dbsp::storage::file::reader::ImmutableFileRef::evict (self=0x7fb4c4041388)
    at crates/dbsp/src/storage/file/reader.rs:1439
#31 0x0000559160c91dee in dbsp::storage::file::reader::{impl#15}::drop (self=0x7fb4c4041388)
    at crates/dbsp/src/storage/file/reader.rs:1416
#32 0x0000559160af7aa5 in core::ptr::drop_in_place<dbsp::storage::file::reader::ImmutableFileRef> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#33 0x00005591609983b9 in core::ptr::drop_in_place<dbsp::storage::file::reader::Reader<(&dyn dbsp::dynamic::data::Data, &dyn dbsp::dynamic::weight::WeightTyped<Type=i64>, ())>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#34 0x000055915fbc39de in alloc::sync::Arc<dbsp::storage::file::reader::Reader<(&dyn dbsp::dynamic::data::Data, &dyn dbsp::dynamic::weight::WeightTyped<Type=i64>, ())>, alloc::alloc::Global>::drop_slow<dbsp::storage::file:--Type <RET> for more, q to quit, c to continue without paging--
:reader::Reader<(&dyn dbsp::dynamic::data::Data, &dyn dbsp::dynamic::weight::WeightTyped<Type=i64>, ())>, alloc::alloc::Global> (self=0x7fb4c411d080)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:2120
#35 0x0000559160baf4b9 in alloc::sync::{impl#42}::drop<dbsp::storage::file::reader::Reader<(&dyn dbsp::dynamic::data::Data, &dyn dbsp::dynamic::weight::WeightTyped<Type=i64>, ())>, alloc::alloc::Global> (
    self=0x7fb4c411d080)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:2854
#36 0x00005591609be131 in core::ptr::drop_in_place<alloc::sync::Arc<dbsp::storage::file::reader::Reader<(&dyn dbsp::dynamic::data::Data, &dyn dbsp::dynamic::weight::WeightTyped<Type=i64>, ())>, alloc::alloc::Global>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#37 0x000055916097850c in core::ptr::drop_in_place<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#38 0x000055915fbc100e in alloc::sync::Arc<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>, alloc::alloc::Global>::drop_slow<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>, alloc::alloc::Global> (self=0x7fb4c40315d0)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:2120
#39 0x0000559160ba84b9 in alloc::sync::{impl#42}::drop<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>, alloc::alloc::Global> (
    self=0x7fb4c40315d0)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:2854
#40 0x00005591609a1b61 in core::ptr::drop_in_place<alloc::sync::Arc<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>, alloc::alloc::Global>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#41 0x00005591609b2472 in core::ptr::drop_in_place<[alloc::sync::Arc<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>, alloc::alloc::Global>]>
    ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#42 0x0000559160cbbe13 in alloc::collections::vec_deque::{impl#1}::drop<alloc::sync::Arc<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>, alloc::alloc::Global>, alloc::alloc::Global> (self=0x7fb4c4057bf8)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/collections/vec_deque/mod.rs:148
#43 0x00005591609e0cc5 in core::ptr::drop_in_place<alloc::collections::vec_deque::VecDeque<alloc::sync::Arc<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>, alloc::alloc::Global>, alloc::alloc::Global>> ()
--Type <RET> for more, q to quit, c to continue without paging--
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#44 0x00005591609b94dd in core::ptr::drop_in_place<dbsp::trace::spine_async::Slot<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#45 0x00005591609d38fa in core::ptr::drop_in_place<[dbsp::trace::spine_async::Slot<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>; 9]> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#46 0x00005591609c284c in core::ptr::drop_in_place<dbsp::trace::spine_async::SharedState<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#47 0x00005591609e4e61 in core::ptr::drop_in_place<core::cell::UnsafeCell<dbsp::trace::spine_async::SharedState<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#48 0x00005591609ed9e5 in core::ptr::drop_in_place<std::sync::poison::mutex::Mutex<dbsp::trace::spine_async::SharedState<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#49 0x000055915fbc42de in alloc::sync::Arc<std::sync::poison::mutex::Mutex<dbsp::trace::spine_async::SharedState<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>>, alloc::alloc::Global>::drop_slow<std::sync::poison::mutex::Mutex<dbsp::trace::spine_async::SharedState<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>>, alloc::alloc::Global> (self=0x7fb4c4048510)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:2120
#50 0x0000559160bb36c9 in alloc::sync::{impl#42}::drop<std::sync::poison::mutex::Mutex<dbsp::trace::spine_async::SharedState<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>>, alloc::alloc::Global> (self=0x7fb4c4048510)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/sync.rs:2854
#51 0x0000559160a03081 in core::ptr::drop_in_place<alloc::sync::Arc<std::sync::poison::mutex::Mutex<dbsp::trace::spine_async::SharedState<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>>, alloc::alloc::Global>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#52 0x00005591609e8fea in core::ptr::drop_in_place<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/m--Type <RET> for more, q to quit, c to continue without paging--
od.rs:550
#53 0x00005591609ff758 in core::ptr::drop_in_place<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#54 0x0000559160a15f61 in core::ptr::drop_in_place<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#55 0x0000559160a3d5bc in core::ptr::drop_in_place<tokio::runtime::task::core::Stage<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>>>
    ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:805
#56 0x000055916497a5df in tokio::runtime::task::core::{impl#6}::set_stage::{closure#0}<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>> (
    ptr=0x7fb4c4045130)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/task/core.rs:429
#57 0x000055916496adce in tokio::loom::std::unsafe_cell::UnsafeCell<tokio::runtime::task::core::Stage<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>>>::with_mut<tokio::runtime::task::core::Stage<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>>, (), tokio::runtime::task::core::{impl#6}::set_stage::{closure_env#0}<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>> (self=0x7fb4c4045130, f=...)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/loom/std/unsafe_cell.rs:16
#58 tokio::runtime::task::core::Core<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>::set_stage<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>> (self=0x7fb4c4045120, stage=...)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/task/core.rs:429
--Type <RET> for more, q to quit, c to continue without paging--
#59 0x0000559164933dbc in tokio::runtime::task::core::Core<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>::drop_future_or_output<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>> (
    self=0x7fb4c4045120)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/task/core.rs:394
#60 0x0000559163b088b4 in tokio::runtime::task::harness::cancel_task::{closure#0}<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>> ()
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/task/harness.rs:503
#61 0x00005591608924a5 in core::ops::function::FnOnce::call_once<tokio::runtime::task::harness::cancel_task::{closure_env#0}<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>, ()> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250
#62 0x0000559162af4fd1 in core::panic::unwind_safe::{impl#23}::call_once<(), tokio::runtime::task::harness::cancel_task::{closure_env#0}<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>> (self=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:274
#63 0x0000559160379dbc in std::panicking::catch_unwind::do_call<core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::cancel_task::{closure_env#0}<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>>, ()> (data=0x7fb8bfffd4f8)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:581
#64 0x000055915fb5173d in __rust_try ()
#65 0x000055915fb3c3ef in std::panicking::catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::cancel_task::{closure_env#0}<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>>> (f=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:544
--Type <RET> for more, q to quit, c to continue without paging--
#66 std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::cancel_task::{closure_env#0}<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>>, ()> (f=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:359
#67 0x0000559163b02df5 in tokio::runtime::task::harness::cancel_task<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>> (core=0x7fb4c4045120)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/task/harness.rs:502
#68 0x0000559163bcb05e in tokio::runtime::task::harness::Harness<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>::shutdown<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>> (self=...)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/task/harness.rs:249
#69 0x000055916339dd6d in tokio::runtime::task::raw::shutdown<core::pin::Pin<alloc::boxed::Box<dbsp::trace::spine_async::{impl#4}::new::{async_block_env#0}<dbsp::trace::ord::file::wset_batch::FileWSet<dyn dbsp::dynamic::data::Data, dyn dbsp::dynamic::weight::WeightTyped<Type=i64>>>, alloc::alloc::Global>>, alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>> (ptr=...)
    at /home/blp/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.50.0/src/runtime/task/raw.rs:377
#70 0x000055916511f528 in tokio::runtime::task::raw::RawTask::shutdown (self=...)
    at src/runtime/task/raw.rs:301
#71 0x000055916510a8c4 in tokio::runtime::task::Task<alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>::shutdown<alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>> (self=...) at src/runtime/task/mod.rs:501
#72 0x000055916510afa6 in tokio::runtime::task::list::OwnedTasks<alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>>::close_and_shutdown_all<alloc::sync::Arc<tokio::runtime::scheduler::multi_thread::handle::Handle, alloc::alloc::Global>> (self=0x7fafb411cd50, start=3)
    at src/runtime/task/list.rs:179
#73 0x0000559165124efb in tokio::runtime::scheduler::multi_thread::worker::Core::pre_shutdown (
    self=0x7fafb411bcf0, worker=0x7fafb411aeb0) at src/runtime/scheduler/multi_thread/worker.rs:1231
#74 0x00005591651282ee in tokio::runtime::scheduler::multi_thread::worker::Context::run (self=0x7fb8bfffdb18, 
    core=0x7fafb411bcf0) at src/runtime/scheduler/multi_thread/worker.rs:610
#75 0x0000559165124a10 in tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}::{closure#0} ()
    at src/runtime/scheduler/multi_thread/worker.rs:536
#76 0x0000559165142170 in tokio::runtime::context::scoped::Scoped<tokio::runtime::scheduler::Context>::set<tokio::runtime::scheduler::Context, tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}::{closure_env#0}, ()> (self=0x7fb8bffff378, t=0x7fb8bfffdb10, f=...) at src/runtime/context/scoped.rs:40
--Type <RET> for more, q to quit, c to continue without paging--
#77 0x000055916511fa9c in tokio::runtime::context::set_scheduler::{closure#0}<(), tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}::{closure_env#0}> (c=0x7fb8bffff350) at src/runtime/context.rs:176
#78 0x000055916513812c in std::thread::local::LocalKey<tokio::runtime::context::Context>::try_with<tokio::runtime::context::Context, tokio::runtime::context::set_scheduler::{closure_env#0}<(), tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}::{closure_env#0}>, ()> (self=0x55916558ac58, f=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:513
#79 0x0000559165136cd2 in std::thread::local::LocalKey<tokio::runtime::context::Context>::with<tokio::runtime::context::Context, tokio::runtime::context::set_scheduler::{closure_env#0}<(), tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}::{closure_env#0}>, ()> (self=0x55916558ac58, 
    f=<error reading variable: Cannot access memory at address 0x2584cf>)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:477
#80 0x000055916511fa21 in tokio::runtime::context::set_scheduler<(), tokio::runtime::scheduler::multi_thread::worker::run::{closure#0}::{closure_env#0}> (v=0x7fb8bfffdb10, f=...) at src/runtime/context.rs:176
#81 0x0000559165124931 in tokio::runtime::scheduler::multi_thread::worker::run::{closure#0} ()
    at src/runtime/scheduler/multi_thread/worker.rs:531
#82 0x0000559165142a95 in tokio::runtime::context::runtime::enter_runtime<tokio::runtime::scheduler::multi_thread::worker::run::{closure_env#0}, ()> (handle=0x7fb8bfffdd20, allow_block_in_place=true, f=...)
    at src/runtime/context/runtime.rs:65
#83 0x000055916512477b in tokio::runtime::scheduler::multi_thread::worker::run (worker=...)
    at src/runtime/scheduler/multi_thread/worker.rs:523
#84 0x0000559165125a22 in tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure#0} ()
    at src/runtime/scheduler/multi_thread/worker.rs:489
#85 0x000055916511b816 in tokio::runtime::blocking::task::{impl#2}::poll<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}, ()> (self=..., _cx=0x7fb8bfffdee0)
    at src/runtime/blocking/task.rs:42
#86 0x00005591650fe40e in tokio::runtime::task::core::{impl#6}::poll::{closure#0}<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule> (ptr=0x7fafb4117f38) at src/runtime/task/core.rs:375
#87 0x00005591650fe0dc in tokio::loom::std::unsafe_cell::UnsafeCell<tokio::runtime::task::core::Stage<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>>>::with_mut<tokio::runtime::task::core::Stage<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>>, core::task::poll::Poll<()>, tokio::runtime::task::core::{impl#6}::poll::{closure_env#0}<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule>> (self=0x7fafb4117f38, f=...) at src/loom/std/unsafe_cell.rs:16
#88 tokio::runtime::task::core::Core<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule>::poll<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule> (self=0x7fafb4117f20, 
    cx=<error reading variable: Cannot access memory at address 0x2584df>) at src/runtime/task/core.rs:364
#89 0x000055916515323b in tokio::runtime::task::harness::poll_future::{closure#0}<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule> () at src/runtime/task/harness.rs:535
--Type <RET> for more, q to quit, c to continue without paging--
#90 0x00005591650f1473 in core::panic::unwind_safe::{impl#23}::call_once<core::task::poll::Poll<()>, tokio::runtime::task::harness::poll_future::{closure_env#0}<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule>> (self=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:274
#91 0x000055916513e57f in std::panicking::catch_unwind::do_call<core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::poll_future::{closure_env#0}<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule>>, core::task::poll::Poll<()>> (data=0x7fb8bfffe028)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:581
#92 0x000055916510500d in __rust_try ()
#93 0x00005591650ffe85 in std::panicking::catch_unwind<core::task::poll::Poll<()>, core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::poll_future::{closure_env#0}<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule>>> (f=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:544
#94 std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<tokio::runtime::task::harness::poll_future::{closure_env#0}<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule>>, core::task::poll::Poll<()>> (f=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:359
#95 0x0000559165152d24 in tokio::runtime::task::harness::poll_future<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule> (core=0x7fafb4117f20, cx=...) at src/runtime/task/harness.rs:523
#96 0x00005591651537ab in tokio::runtime::task::harness::Harness<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule>::poll_inner<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule> (self=0x7fb8bfffe2a8) at src/runtime/task/harness.rs:210
#97 0x0000559165153f69 in tokio::runtime::task::harness::Harness<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule>::poll<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule> (
    self=...) at src/runtime/task/harness.rs:155
#98 0x000055916511eecf in tokio::runtime::task::raw::poll<tokio::runtime::blocking::task::BlockingTask<tokio::runtime::scheduler::multi_thread::worker::{impl#0}::launch::{closure_env#0}>, tokio::runtime::blocking::schedule::BlockingSchedule> (ptr=...) at src/runtime/task/raw.rs:337
#99 0x000055916511f3a7 in tokio::runtime::task::raw::RawTask::poll (self=...) at src/runtime/task/raw.rs:267
#100 0x000055916510aa76 in tokio::runtime::task::UnownedTask<tokio::runtime::blocking::schedule::BlockingSchedule>::run<tokio::runtime::blocking::schedule::BlockingSchedule> (self=...) at src/runtime/task/mod.rs:547
#101 0x000055916510c9b9 in tokio::runtime::blocking::pool::Task::run (self=...)
--Type <RET> for more, q to quit, c to continue without paging--
    at src/runtime/blocking/pool.rs:161
#102 0x000055916510cbe4 in tokio::runtime::blocking::pool::Inner::run (self=0x7fafb411bdc0, 
    worker_thread_id=0) at src/runtime/blocking/pool.rs:518
#103 0x000055916510deea in tokio::runtime::blocking::pool::{impl#6}::spawn_thread::{closure#0} ()
    at src/runtime/blocking/pool.rs:474
#104 0x00005591650ff81d in std::sys::backtrace::__rust_begin_short_backtrace<tokio::runtime::blocking::pool::{impl#6}::spawn_thread::{closure_env#0}, ()> (
    f=<error reading variable: Cannot access memory at address 0x251bec>)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:160
#105 0x000055916512ea69 in std::thread::lifecycle::spawn_unchecked::{closure#1}::{closure#0}<tokio::runtime::blocking::pool::{impl#6}::spawn_thread::{closure_env#0}, ()> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/lifecycle.rs:92
#106 0x00005591650f1633 in core::panic::unwind_safe::{impl#23}::call_once<(), std::thread::lifecycle::spawn_unchecked::{closure#1}::{closure_env#0}<tokio::runtime::blocking::pool::{impl#6}::spawn_thread::{closure_env#0}, ()>> (self=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:274
#107 0x000055916513e50b in std::panicking::catch_unwind::do_call<core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked::{closure#1}::{closure_env#0}<tokio::runtime::blocking::pool::{impl#6}::spawn_thread::{closure_env#0}, ()>>, ()> (data=0x7fb8bfffe968)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:581
#108 0x000055916513635d in __rust_try ()
#109 0x000055916512e6ea in std::panicking::catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked::{closure#1}::{closure_env#0}<tokio::runtime::blocking::pool::{impl#6}::spawn_thread::{closure_env#0}, ()>>> (f=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:544
#110 std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<std::thread::lifecycle::spawn_unchecked::{closure#1}::{closure_env#0}<tokio::runtime::blocking::pool::{impl#6}::spawn_thread::{closure_env#0}, ()>>, ()> (f=...)
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:359
#111 std::thread::lifecycle::spawn_unchecked::{closure#1}<tokio::runtime::blocking::pool::{impl#6}::spawn_thread::{closure_env#0}, ()> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/lifecycle.rs:90
#112 0x000055916510f7e2 in core::ops::function::FnOnce::call_once<std::thread::lifecycle::spawn_unchecked::{closure_env#1}<tokio::runtime::blocking::pool::{impl#6}::spawn_thread::{closure_env#0}, ()>, ()> ()
    at /home/blp/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250
#113 0x000055916526c91f in alloc::boxed::{impl#31}::call_once<(), (dyn core::ops::function::FnOnce<(), Output=()> + core::marker::Send), alloc::alloc::Global> () at library/alloc/src/boxed.rs:2206
--Type <RET> for more, q to quit, c to continue without paging--
#114 std::sys::thread::unix::{impl#2}::new::thread_start () at library/std/src/sys/thread/unix.rs:118
#115 0x00007fbbcab88464 in start_thread (arg=<optimized out>) at pthread_create.c:448
#116 0x00007fbbcac0b5ac in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78

@blp
Copy link
Copy Markdown
Member Author

blp commented Apr 2, 2026

The panic comes inside Drop for ImmutableFileRef, which atempts to evict the file being dropped from the buffer cache. But ImmutableFileRef doesn't have a reference to the BufferCache, it only has a fn() -> Arc<BufferCache> that it can call to get a buffer cache. This fn is actually Runtime::buffer_cache, which is what's panicking.

I guess what's happening is that a merger thread is opening a Reader and taking an Arc to it, and that occasionally the last reference to that Arc is somehow dropped outside the merger task but still in a thread created by the merger (and therefore marked as ThreadType::Background). That would naturally produce the panic in question.

@gz @ryzhyk Any thoughts?

@blp
Copy link
Copy Markdown
Member Author

blp commented Apr 2, 2026

One option would be to drop the attempt to evict data in the ImmutableFileRef drop implementation. I added that because I guessed it would help, but I do not have any measurements demonstrating it.

@blp
Copy link
Copy Markdown
Member Author

blp commented Apr 2, 2026

Another solution would be to give ImmutableFileRef a direct handle to its buffer cache rather than a function to call to get one. The status quo is there because buffer caches were (and often are) worker- or thread-specific. But then, at least for the thread-specific case, we'd have to figure out how or when to switch buffer caches.

If we had only a single buffer cache for the runtime, there would not be a problem.

@ryzhyk
Copy link
Copy Markdown
Contributor

ryzhyk commented Apr 2, 2026

I guess the question is how can this happen outside of one of the tasks we spawn? We terminate the tokio runtime when killing the DBSP runtime like this:

        // Terminate the tokio merger runtime.
        if let Some(tokio_merger_runtime) = self
            .runtime
            .inner()
            .tokio_merger_runtime
            .lock()
            .unwrap()
            .take()
        {
            // Block until all running merger tasks have yielded. At this point, the tokio runtime will have shut down automatically.
            drop(tokio_merger_runtime);
        }

This is probably when this happens. But why?

@gz
Copy link
Copy Markdown
Contributor

gz commented Apr 2, 2026

One option would be to drop the attempt to evict data in the ImmutableFileRef drop implementation. I added that because I guessed it would help, but I do not have any measurements demonstrating it.

Since we don't know if it helps we could just drop this 'feature'.

I was questioning this choice when we worked on FBuf allocation.
I agree it could be helpful but I think most caches don't do it and it could also be harmful causing somewhat unnecessary churn on the cache.

If we trust the eviction policy to be "good enough" it should be fine to just skip the step.
It might also happen because of our Runtime/NoRuntime mess in testing.

@ryzhyk
Copy link
Copy Markdown
Contributor

ryzhyk commented Apr 2, 2026

Apparently this is to be expected:
image

@blp
Copy link
Copy Markdown
Member Author

blp commented Apr 2, 2026

Destructors are always trouble.

@blp
Copy link
Copy Markdown
Member Author

blp commented Apr 2, 2026

I added a commit that should fix the occasional panic. @gz @ryzhyk I would appreciate your opinion on this fix.

Copy link
Copy Markdown
Contributor

@ryzhyk ryzhyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix makes sense.

`RefCell` is relatively expensive because it maintains a borrow counter
and associated lock-like logic.  `Cell` is just a transparent wrapper
around the inner type, so that it uses less time and space.

Signed-off-by: Ben Pfaff <[email protected]>
@blp blp enabled auto-merge April 3, 2026 14:50
@blp blp added this pull request to the merge queue Apr 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 3, 2026
Sometimes, running the unit tests failed with:

```
panicked at crates/dbsp/src/circuit/runtime.rs:972:64:
cannot access a task-local storage value without setting it first
thread panicked while processing panic. aborting.
Aborted (core dumped)
```

The panic comes inside Drop for ImmutableFileRef, which attempts to
evict the file being dropped from the buffer cache.  But
ImmutableFileRef doesn't have a reference to the BufferCache, it only
has a fn() -> Arc<BufferCache> that it can call to get a buffer
cache.  This fn is actually Runtime::buffer_cache, which is what's
panicking.

The problem is that tokio task shutdown does not provide values for
task-local variables, which is what stores the buffer cache.  This
commit avoids the problem by allowing the buffer cache to be
unavailable for Drop in ImmutableFileRef.  This requires some code
refactoring so that the cache fn, and Runtime::buffer_cache(),
return an Option.

Signed-off-by: Ben Pfaff <[email protected]>
@blp blp enabled auto-merge April 3, 2026 15:32
@blp blp added this pull request to the merge queue Apr 3, 2026
Merged via the queue into main with commit 7d27972 Apr 3, 2026
1 check passed
@blp blp deleted the cell branch April 3, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DBSP core Related to the core DBSP library performance rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants