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

test_format_minimal_diff is not reliable #79

Closed
DavisVaughan opened this issue Dec 3, 2024 · 1 comment · Fixed by #80
Closed

test_format_minimal_diff is not reliable #79

DavisVaughan opened this issue Dec 3, 2024 · 1 comment · Fixed by #80

Comments

@DavisVaughan
Copy link
Collaborator

DavisVaughan commented Dec 3, 2024

We occasionally see this in CI without any reason why

test handlers_format::tests::test_format_minimal_diff has been running for over 60 seconds

https://github.com/posit-dev/air/actions/runs/12055757729/job/33616802860

@DavisVaughan
Copy link
Collaborator Author

DavisVaughan commented Dec 3, 2024

I can reproduce a test with RUST_BACKTRACE=full cargo test -p lsp -- --nocapture and the --nocapture seems required to see the panic otherwise we often just get "passed"

My guess is

  • tests are run in parallel
  • but AUXILIARY_EVENT_TX is a global
  • if test A sets it, then test B runs before test A finishes, then test B overrides it and test A panics on the recv() end because its sender got dropped

Can confirm the problem goes away with RUST_BACKTRACE=full cargo test -p lsp -- --nocapture --test-threads=1

thread 'handlers_format::tests::test_format' panicked at crates/lsp/src/main_loop.rs:431:72:
called `Option::unwrap()` on a `None` value
stack backtrace:
test tower_lsp::tests::test_init ... ok
   0:        0x1031349e4 - std::backtrace_rs::backtrace::libunwind::trace::h1c3451b342542f10
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:        0x1031349e4 - std::backtrace_rs::backtrace::trace_unsynchronized::h3743cad8cc2d54de
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x1031349e4 - std::sys::backtrace::_print_fmt::h31ad576fee12d4ee
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/backtrace.rs:66:9
   3:        0x1031349e4 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::habbf9c4f641febb1
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/backtrace.rs:39:26
   4:        0x103153440 - core::fmt::rt::Argument::fmt::h54965d9b1ee82264
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/rt.rs:177:76
   5:        0x103153440 - core::fmt::write::ha36a8060c13608ea
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/fmt/mod.rs:1178:21
   6:        0x103130ef8 - std::io::Write::write_fmt::h431832c8ebcc85c9
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/io/mod.rs:1823:15
   7:        0x103135fa4 - std::sys::backtrace::BacktraceLock::print::hd085ca0c3911e184
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/backtrace.rs:42:9
   8:        0x103135fa4 - std::panicking::default_hook::{{closure}}::h4aa1f60327dfff6a
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:266:22
   9:        0x103135b54 - std::panicking::default_hook::h4ebc6eb4ae179807
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:293:9
  10:        0x103136a20 - std::panicking::rust_panic_with_hook::h6a84efe4dcab239c
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:797:13
  11:        0x103136424 - std::panicking::begin_panic_handler::{{closure}}::h5eef292190467fef
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:664:13
  12:        0x103134ea8 - std::sys::backtrace::__rust_end_short_backtrace::hd7e7925203f20af9
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/backtrace.rs:170:18
  13:        0x103136114 - rust_begin_unwind
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:662:5
  14:        0x10317a7a8 - core::panicking::panic_fmt::h410d3f147658259b
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:74:14
  15:        0x10317a814 - core::panicking::panic::hee236ca94fc05047
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:148:5
  16:        0x10317a730 - core::option::unwrap_failed::h187ebe480b20e6be
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/option.rs:2015:5
  17:        0x102aaff10 - core::option::Option<T>::unwrap::hff3edf92152672da
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/option.rs:965:21
  18:        0x102aaff10 - lsp::main_loop::AuxiliaryState::next_event::{{closure}}::h9faa9edb42ffbcce
                               at /Users/davis/files/programming/air/crates/lsp/src/main_loop.rs:431:66
  19:        0x102aaf588 - lsp::main_loop::AuxiliaryState::start::{{closure}}::h9d24afd976d40e67
                               at /Users/davis/files/programming/air/crates/lsp/src/main_loop.rs:416:37
  20:        0x102aae974 - lsp::main_loop::GlobalState::main_loop::{{closure}}::{{closure}}::h8cc3e4081cfffc8b
                               at /Users/davis/files/programming/air/crates/lsp/src/main_loop.rs:207:44
  21:        0x1028c3224 - tokio::runtime::task::core::Core<T,S>::poll::{{closure}}::h77ccdd3251d7b989
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/task/core.rs:331:17
  22:        0x1028c2288 - tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut::hd32b763453ed2e6b
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/loom/std/unsafe_cell.rs:16:9
  23:        0x1028c2288 - tokio::runtime::task::core::Core<T,S>::poll::h18b93681f3bd4aed
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/task/core.rs:320:13
  24:        0x102cab6a0 - tokio::runtime::task::harness::poll_future::{{closure}}::h0f3fe77b4c1361e5
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/task/harness.rs:499:19
  25:        0x1029a57f4 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hc2de0f1aed172a9f
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panic/unwind_safe.rs:272:9
  26:        0x102b8c920 - std::panicking::try::do_call::h69c30ad7fc4a3cf3
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:554:40
  27:        0x102ca0300 - ___rust_try
  28:        0x102c9f268 - std::panicking::try::h29b09161529454fb
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:518:19
  29:        0x102c9f268 - std::panic::catch_unwind::hc0d609defe967906
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panic.rs:345:14
  30:        0x102caa85c - tokio::runtime::task::harness::poll_future::h7d410eec86e7bf4e
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/task/harness.rs:487:18
  31:        0x102cad97c - tokio::runtime::task::harness::Harness<T,S>::poll_inner::hf246dcc3bd1c2951
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/task/harness.rs:209:27
  32:        0x102cb06a0 - tokio::runtime::task::harness::Harness<T,S>::poll::hd410dc501ac73b79
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/task/harness.rs:154:15
  33:        0x102b359bc - tokio::runtime::task::raw::poll::h17cfd6c194d4ac87
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/task/raw.rs:271:5
  34:        0x102fc3acc - tokio::runtime::task::raw::RawTask::poll::hea77bda0435a39c7
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/task/raw.rs:201:18
  35:        0x102ca1c74 - tokio::runtime::task::LocalNotified<S>::run::h1148709e6e47d73d
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/task/mod.rs:435:9
  36:        0x1028cb154 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::{{closure}}::h7ce3e337a34314cb
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/scheduler/current_thread/mod.rs:770:25
  37:        0x1028c9b24 - tokio::runtime::coop::with_budget::hcb7bb639114eb5a3
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/coop.rs:107:5
  38:        0x1028c9b24 - tokio::runtime::coop::budget::h33c48f2a4abe5346
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/coop.rs:73:5
  39:        0x1028c9b24 - tokio::runtime::scheduler::current_thread::Context::run_task::{{closure}}::h00181eabc9b2edcf
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/scheduler/current_thread/mod.rs:364:43
  40:        0x1028c9510 - tokio::runtime::scheduler::current_thread::Context::enter::h34231b9dcb26d6a2
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/scheduler/current_thread/mod.rs:428:19
  41:        0x1028c98e0 - tokio::runtime::scheduler::current_thread::Context::run_task::h5afe5ae8c0e7cb61
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/scheduler/current_thread/mod.rs:364:23
  42:        0x1028ca948 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::{{closure}}::h235dace1fd8c2ca9
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/scheduler/current_thread/mod.rs:769:35
  43:        0x1028ca2d8 - tokio::runtime::scheduler::current_thread::CoreGuard::enter::{{closure}}::hae79b1dea7891ec4
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/scheduler/current_thread/mod.rs:807:68
  44:        0x102b780ac - tokio::runtime::context::scoped::Scoped<T>::set::hc4cea96024752bb2
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/context/scoped.rs:40:9
  45:        0x102c313d4 - tokio::runtime::context::set_scheduler::{{closure}}::hbf15d03963fd4191
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/context.rs:180:26
  46:        0x102b80f44 - std::thread::local::LocalKey<T>::try_with::h64060f1c4323a193
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:283:12
  47:        0x102b7ff80 - std::thread::local::LocalKey<T>::with::h47b2cb734e9a1796
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/local.rs:260:9
  48:        0x102c31300 - tokio::runtime::context::set_scheduler::hae6be6f9f08235c9
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/context.rs:180:9
  49:        0x1028ca12c - tokio::runtime::scheduler::current_thread::CoreGuard::enter::h6c548c73d39f5acb
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/scheduler/current_thread/mod.rs:807:27
  50:        0x1028ca328 - tokio::runtime::scheduler::current_thread::CoreGuard::block_on::h0125bd0d94355f9a
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/scheduler/current_thread/mod.rs:716:19
  51:        0x1028c791c - tokio::runtime::scheduler::current_thread::CurrentThread::block_on::{{closure}}::h9454407f2b128de8
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/scheduler/current_thread/mod.rs:196:28
  52:        0x102d05354 - tokio::runtime::context::runtime::enter_runtime::h41f7487e125500f6
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/context/runtime.rs:65:16
  53:        0x1028c7430 - tokio::runtime::scheduler::current_thread::CurrentThread::block_on::h741d590ada1db4f9
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/scheduler/current_thread/mod.rs:184:9
  54:        0x102c23ae0 - tokio::runtime::runtime::Runtime::block_on_inner::h90afc99fbd2caff0
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/runtime.rs:368:47
  55:        0x102c23c98 - tokio::runtime::runtime::Runtime::block_on::h33ed8d3397edbdca
                               at /Users/davis/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.1/src/runtime/runtime.rs:342:13
  56:        0x102a0bcac - lsp::handlers_format::tests::test_format::h4db267a65c4ced40
                               at /Users/davis/files/programming/air/crates/lsp/src/handlers_format.rs:75:20
  57:        0x102b3373c - lsp::handlers_format::tests::test_format::{{closure}}::he9e57f7e51cd6f32
                               at /Users/davis/files/programming/air/crates/lsp/src/handlers_format.rs:51:21
  58:        0x1028f2ff8 - core::ops::function::FnOnce::call_once::h913460dc155312aa
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/ops/function.rs:250:5
  59:        0x102e2be9c - core::ops::function::FnOnce::call_once::h2dc2ae3d5deab128
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/ops/function.rs:250:5
  60:        0x102e2be9c - test::__rust_begin_short_backtrace::ha74869ac477f01d4
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/test/src/lib.rs:620:18
  61:        0x102e2b710 - test::run_test_in_process::{{closure}}::h480e4aa17f895fab
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/test/src/lib.rs:643:60
  62:        0x102e2b710 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::he972b835bfbe1a74
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panic/unwind_safe.rs:272:9
  63:        0x102e2b710 - std::panicking::try::do_call::h6d242d7a00c26634
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:554:40
  64:        0x102e2b710 - std::panicking::try::hb95de8c02276d3a3
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:518:19
  65:        0x102e2b710 - std::panic::catch_unwind::ha1de2aaaa7ebc727
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panic.rs:345:14
  66:        0x102e2b710 - test::run_test_in_process::he8812b09a718bc7e
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/test/src/lib.rs:643:27
  67:        0x102e2b710 - test::run_test::{{closure}}::h2a5b46f746d71bd1
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/test/src/lib.rs:564:43
  68:        0x102dfb7a0 - test::run_test::{{closure}}::h61d08600987824eb
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/test/src/lib.rs:594:41
  69:        0x102dfb7a0 - std::sys::backtrace::__rust_begin_short_backtrace::h8712ad22d62bd1c4
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/backtrace.rs:154:18
  70:        0x102dfe908 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h4a31c94c016920f8
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/mod.rs:522:17
  71:        0x102dfe908 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hb12f0f3e20fc7e49
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panic/unwind_safe.rs:272:9
  72:        0x102dfe908 - std::panicking::try::do_call::hc89f2e3a18dc8949
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:554:40
  73:        0x102dfe908 - std::panicking::try::h155ce7ca424a9125
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:518:19
  74:        0x102dfe908 - std::panic::catch_unwind::h0fce6398764430bd
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panic.rs:345:14
  75:        0x102dfe908 - std::thread::Builder::spawn_unchecked_::{{closure}}::h38c8d2c04ffb7937
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/thread/mod.rs:521:30
  76:        0x102dfe908 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h28859a09daa84c0f
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/ops/function.rs:250:5
  77:        0x10313a9f0 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2fa7f2d055a8b06a
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/boxed.rs:2231:9
  78:        0x10313a9f0 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h53b33f8374f8384c
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/alloc/src/boxed.rs:2231:9
  79:        0x10313a9f0 - std::sys::pal::unix::thread::Thread::new::thread_start::hd88bc8e95f2ca709
                               at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/sys/pal/unix/thread.rs:105:17
  80:        0x19c0c7fa8 - __pthread_joiner_wake
test handlers_format::tests::test_format_minimal_diff ... ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant