PolyMeilex / rfd

Rusty File Dialog
MIT License
608 stars 69 forks source link

GTK AsyncMessageDialog crashes when cancelled #219

Open matthias-stemmler opened 3 weeks ago

matthias-stemmler commented 3 weeks ago

Minimal reproducing example:

// main.rs
fn main() {
    async_std::task::block_on(rfd::AsyncMessageDialog::new().show());
}
# Cargo.toml
[dependencies]
async-std = "1.13.0"
rfd = { version = "0.15.0", features = ["gtk3"], default-features = false }

Run cargo run and cancel the dialog: dialog

Then the process crashes with the following message:

thread '<unnamed>' panicked at [redacted]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rfd-0.15.0/src/backend/gtk3/message_dialog.rs:212:18:
internal error: entered unreachable code
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at core/src/panicking.rs:221:5:
panic in a function that cannot unwind
stack backtrace:
   0:     0x6058ba9bbeda - std::backtrace_rs::backtrace::libunwind::trace::h387bc295b31c54d0
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/../../backtrace/src/backtrace/libunwind.rs:116:5
   1:     0x6058ba9bbeda - std::backtrace_rs::backtrace::trace_unsynchronized::h263a13546387b72c
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x6058ba9bbeda - std::sys::backtrace::_print_fmt::h0afacf886ea25177
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/sys/backtrace.rs:66:9
   3:     0x6058ba9bbeda - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h6c4b83e893faf091
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/sys/backtrace.rs:39:26
   4:     0x6058ba9d91c3 - core::fmt::rt::Argument::fmt::hadf774d1809a5ebe
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/core/src/fmt/rt.rs:177:76
   5:     0x6058ba9d91c3 - core::fmt::write::hd89ed6858e8e158b
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/core/src/fmt/mod.rs:1186:21
   6:     0x6058ba9b9863 - std::io::Write::write_fmt::hcdd8cc609dcb58dc
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/io/mod.rs:1839:15
   7:     0x6058ba9bbd22 - std::sys::backtrace::BacktraceLock::print::h6c7b9f81c275a146
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/sys/backtrace.rs:42:9
   8:     0x6058ba9bce0c - std::panicking::default_hook::{{closure}}::hb5e24153c391de56
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/panicking.rs:268:22
   9:     0x6058ba9bcc52 - std::panicking::default_hook::h387c3348306e6016
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/panicking.rs:295:9
  10:     0x6058ba9bd3e7 - std::panicking::rust_panic_with_hook::h3020a51b596e534d
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/panicking.rs:801:13
  11:     0x6058ba9bd246 - std::panicking::begin_panic_handler::{{closure}}::h8ec0645c1568988f
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/panicking.rs:667:13
  12:     0x6058ba9bc3b9 - std::sys::backtrace::__rust_end_short_backtrace::h3ebc0d178164cc27
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/sys/backtrace.rs:170:18
  13:     0x6058ba9bcf0c - rust_begin_unwind
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/panicking.rs:665:5
  14:     0x6058ba8f139d - core::panicking::panic_nounwind_fmt::runtime::h95521a14dba7685f
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/core/src/panicking.rs:112:18
  15:     0x6058ba8f139d - core::panicking::panic_nounwind_fmt::h8b5fad1e6c66f8d0
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/core/src/panicking.rs:122:5
  16:     0x6058ba8f1432 - core::panicking::panic_nounwind::h237344d7609da601
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/core/src/panicking.rs:221:5
  17:     0x6058ba8f1595 - core::panicking::panic_cannot_unwind::h301fb4ffe84ccdc1
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/core/src/panicking.rs:310:5
  18:     0x6058ba9034e2 - rfd::backend::gtk3::gtk_future::connect_response::response_trampoline::hfb7fee5a35ecfd9e
                               at [redacted]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rfd-0.15.0/src/backend/gtk3/gtk_future.rs:122:5
  19:     0x792ada618608 - g_cclosure_marshal_VOID__INTv
  20:     0x792ada63a6bd - <unknown>
  21:     0x792ada63a7c1 - g_signal_emit_valist
  22:     0x792ada63a883 - g_signal_emit
  23:     0x792ad9f5f912 - <unknown>
  24:     0x792ad9e982f7 - <unknown>
  25:     0x792ada63a6bd - <unknown>
  26:     0x792ada63a7c1 - g_signal_emit_valist
  27:     0x792ada63a883 - g_signal_emit
  28:     0x792ada166b64 - <unknown>
  29:     0x792ada004359 - gtk_main_do_event
  30:     0x792ad993f407 - <unknown>
  31:     0x792ad9998c6e - <unknown>
  32:     0x792ad9d145b5 - <unknown>
  33:     0x792ad9d73717 - <unknown>
  34:     0x792ad9d13a53 - g_main_context_iteration
  35:     0x792ad9ffec19 - gtk_main_iteration
  36:     0x6058ba8fe700 - rfd::backend::gtk3::utils::GtkGlobalThread::new::{{closure}}::h8d0d0bc02c71a52c
                               at [redacted]/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rfd-0.15.0/src/backend/gtk3/utils.rs:42:21
  37:     0x6058ba8fe29e - std::sys::backtrace::__rust_begin_short_backtrace::ha3f862c0c66d9532
                               at [redacted]/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs:154:18
  38:     0x6058ba904b7b - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h47ba79742464122a
                               at [redacted]/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:538:17
  39:     0x6058ba8fd8cf - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h046dd2cb8e7d32d5
                               at [redacted]/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panic/unwind_safe.rs:272:9
  40:     0x6058ba8ff616 - std::panicking::try::do_call::h10f8d9c602db4ade
                               at [redacted]/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:557:40
  41:     0x6058ba90503b - __rust_try
  42:     0x6058ba904997 - std::panicking::try::h51b7481e2a14d0d1
                               at [redacted]/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:520:19
  43:     0x6058ba904997 - std::panic::catch_unwind::hcfb18a40f9760b8a
                               at [redacted]/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:358:14
  44:     0x6058ba904997 - std::thread::Builder::spawn_unchecked_::{{closure}}::h657aa1aa3b924bae
                               at [redacted]/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/mod.rs:537:30
  45:     0x6058ba8fa1bf - core::ops::function::FnOnce::call_once{{vtable.shim}}::h577f5bb14f6ea906
                               at [redacted]/.rustup/toolchains/beta-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
  46:     0x6058ba9bf12b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hcdcece852699ba6b
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/alloc/src/boxed.rs:2454:9
  47:     0x6058ba9bf12b - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2dd5af36c674bb7c
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/alloc/src/boxed.rs:2454:9
  48:     0x6058ba9bf12b - std::sys::pal::unix::thread::Thread::new::thread_start::hab3b8ef294ca7a23
                               at /rustc/0125edf41b8ce32db5c2cce0c83e32ad2e4dde17/library/std/src/sys/pal/unix/thread.rs:105:17
  49:     0x792ad9a9ca94 - start_thread
                               at ./nptl/pthread_create.c:447:8
  50:     0x792ad9b29c3c - clone3
                               at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
  51:                0x0 - <unknown>
thread caused non-unwinding panic. aborting.
Aborted (core dumped)
PolyMeilex commented 3 weeks ago

The simplest solution would be to use xdg-portal feature instead of gtk3.

matthias-stemmler commented 3 weeks ago

@PolyMeilex The docs sounded like AsyncMessageDialog was only available under gtk3, not xdg-portal:

The XDG Desktop Portal has no API for message dialogs, so the MessageDialog and AsyncMessageDialog structs will not build with this backend.

Anyway, I'm using this through Tauri, which uses gtk3. It's not an issue for me at the moment, just wanted to let you know.