Skip to content

Crash when quitting in multiprocess mode #41437

@webbeef

Description

@webbeef

To reproduce, launch with ./mach run -M . Output is:

❯ ./mach run -M
No build type specified so assuming `--dev`.
BHM is gone: "SendError(..)" (thread Script#1, at components/background_hang_monitor/background_hang_monitor.rs:138)
servo on  main [?] via 🦀 v1.91.0 took 5s 
❯    0: servoshell::backtrace::print
             at /home/webbeef/servo/ports/servoshell/backtrace.rs:18:5
   1: servoshell::panic_hook::panic_hook
             at /home/webbeef/servo/ports/servoshell/panic_hook.rs:40:17
   2: core::ops::function::Fn::call
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:79:5
   3: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/alloc/src/boxed.rs:1999:9
      std::panicking::panic_with_hook
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:842:13
   4: std::panicking::panic_handler::{{closure}}
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:707:13
   5: std::sys::backtrace::__rust_end_short_backtrace
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/sys/backtrace.rs:174:18
   6: __rustc::rust_begin_unwind
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:698:5
   7: core::panicking::panic_fmt
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/core/src/panicking.rs:75:14
   8: core::result::unwrap_failed
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/core/src/result.rs:1855:5
   9: core::result::Result<T,E>::expect
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1178:23
  10: background_hang_monitor::background_hang_monitor::BackgroundHangMonitorChan::send
             at /home/webbeef/servo/components/background_hang_monitor/background_hang_monitor.rs:138:14
  11: <background_hang_monitor::background_hang_monitor::BackgroundHangMonitorChan as background_hang_monitor_api::BackgroundHangMonitor>::unregister
             at /home/webbeef/servo/components/background_hang_monitor/background_hang_monitor.rs:157:14
  12: script::script_thread::ScriptThread::handle_exit_script_thread_msg
             at /home/webbeef/servo/components/script/script_thread.rs:2999:38
  13: script::script_thread::ScriptThread::handle_msgs
             at /home/webbeef/servo/components/script/script_thread.rs:1385:30
  14: script::script_thread::ScriptThread::start
             at /home/webbeef/servo/components/script/script_thread.rs:1015:20
  15: <script::script_thread::ScriptThread as layout_api::ScriptThreadFactory>::create::{{closure}}::{{closure}}
             at /home/webbeef/servo/components/script/script_thread.rs:458:38
  16: profile_traits::mem::ProfilerChan::run_with_memory_reporting
             at /home/webbeef/servo/components/shared/profile/mem.rs:142:9
  17: <script::script_thread::ScriptThread as layout_api::ScriptThreadFactory>::create::{{closure}}
             at /home/webbeef/servo/components/script/script_thread.rs:457:40
  18: std::sys::backtrace::__rust_begin_short_backtrace
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:158:18
  19: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:559:17
  20: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:274:9
  21: std::panicking::catch_unwind::do_call
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:590:40
  22: __rust_try
  23: std::panicking::catch_unwind
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:553:19
      std::panic::catch_unwind
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:359:14
      std::thread::Builder::spawn_unchecked_::{{closure}}
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:557:30
  24: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  25: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/alloc/src/boxed.rs:1985:9
      std::sys::thread::unix::Thread::new::thread_start
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/sys/thread/unix.rs:126:17
  26: start_thread
             at ./nptl/pthread_create.c:447:8
  27: clone3
             at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
[2025-12-20T23:56:29Z ERROR servoshell::panic_hook] BHM is gone: "SendError(..)"
Failed to join on the script thread.: Any { .. } (thread main, at components/servo/servo.rs:1090)
   0: servoshell::backtrace::print
             at /home/webbeef/servo/ports/servoshell/backtrace.rs:18:5
   1: servoshell::panic_hook::panic_hook
             at /home/webbeef/servo/ports/servoshell/panic_hook.rs:40:17
   2: core::ops::function::Fn::call
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:79:5
   3: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/alloc/src/boxed.rs:1999:9
      std::panicking::panic_with_hook
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:842:13
   4: std::panicking::panic_handler::{{closure}}
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:707:13
   5: std::sys::backtrace::__rust_end_short_backtrace
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/sys/backtrace.rs:174:18
   6: __rustc::rust_begin_unwind
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:698:5
   7: core::panicking::panic_fmt
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/core/src/panicking.rs:75:14
   8: core::result::unwrap_failed
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/core/src/result.rs:1855:5
   9: core::result::Result<T,E>::expect
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:1178:23
  10: servo::servo::run_content_process
             at /home/webbeef/servo/components/servo/servo.rs:1090:18
  11: servoshell::desktop::cli::main
             at /home/webbeef/servo/ports/servoshell/desktop/cli.rs:23:64
  12: servoshell::main
             at /home/webbeef/servo/ports/servoshell/lib.rs:46:5
  13: servo::main
             at /home/webbeef/servo/ports/servoshell/main.rs:39:13
  14: core::ops::function::FnOnce::call_once
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  15: std::sys::backtrace::__rust_begin_short_backtrace
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:158:18
  16: std::rt::lang_start::{{closure}}
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:206:18
  17: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/core/src/ops/function.rs:287:21
      std::panicking::catch_unwind::do_call
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:590:40
      std::panicking::catch_unwind
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:553:19
      std::panic::catch_unwind
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panic.rs:359:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/rt.rs:175:24
      std::panicking::catch_unwind::do_call
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:590:40
      std::panicking::catch_unwind
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panicking.rs:553:19
      std::panic::catch_unwind
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/panic.rs:359:14
      std::rt::lang_start_internal
             at /rustc/f8297e351a40c1439a467bbbb6879088047f50b3/library/std/src/rt.rs:171:5
  18: std::rt::lang_start
             at /home/webbeef/.rustup/toolchains/1.91.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:205:5
  19: main
  20: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  21: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:360:3
  22: _start
[2025-12-20T23:56:29Z ERROR servoshell::panic_hook] Failed to join on the script thread.: Any { .. }

This patch fixes the issue but there can be a more correct fix in the multiprocess case.

diff --git a/components/background_hang_monitor/background_hang_monitor.rs b/components/background_hang_monitor/background_hang_monitor.rs
index c038c17ada4..190202ea113 100644
--- a/components/background_hang_monitor/background_hang_monitor.rs
+++ b/components/background_hang_monitor/background_hang_monitor.rs
@@ -133,9 +133,7 @@ impl BackgroundHangMonitorChan {
     }
 
     fn send(&self, msg: MonitoredComponentMsg) {
-        self.sender
-            .send((self.component_id.clone(), msg))
-            .expect("BHM is gone");
+        let _ = self.sender.send((self.component_id.clone(), msg));
     }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-multiprocessIssues specific to using multiple processes.I-crashNo impact; the issue is one of maintainability or tidiness.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions