gabm / Satty

Satty - Modern Screenshot Annotation. A tool inspired by Swappy and Flameshot.
Mozilla Public License 2.0
383 stars 18 forks source link

[bug] using the chrono formatting options for file name causes satty to hang and crash on save #91

Open a-viv-a opened 3 weeks ago

a-viv-a commented 3 weeks ago

When using the chrono formatting options, satty hangs and crashes. I used --output-filename /home/aviva/screenshots/%Y-%b/%a-%H:%M:%S:%1f.png (probably change to be appropriate on your system?) and when I click the save button, satty locks up. If you wait long enough it seems to die, but the following trace is from when I killed satty.

thread 'main' panicked at library/alloc/src/fmt.rs:612:32:
a formatting trait implementation returned an error: Error
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: alloc::fmt::format::format_inner
   4: satty::sketch_board::SketchBoard::handle_save
   5: relm4::component::sync::traits::Component::update_with_view
   6: glib::main_context_futures::<impl glib::auto::main_context::MainContext>::spawn_local_with_priority::{{closure}}
   7: glib::main_context::<impl glib::auto::main_context::MainContext>::with_thread_default
   8: glib::main_context_futures::TaskSource::dispatch
   9: g_main_dispatch
  10: g_main_context_iterate_unlocked.isra.0
  11: g_main_context_iteration
  12: g_application_run
  13: gio::application::ApplicationExtManual::run_with_args
  14: relm4::app::RelmApp<M>::run
  15: satty::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

same deal but "full" backtrace:

thread 'main' panicked at library/alloc/src/fmt.rs:612:32:
a formatting trait implementation returned an error: Error
stack backtrace:
   0:     0x55ffd0b781f7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h83d3e31f1809523c
   1:     0x55ffd0bacf00 - core::fmt::write::h76573a5842288faa
   2:     0x55ffd0b92255 - std::io::Write::write_fmt::hb095d534967ab243
   3:     0x55ffd0b77fc4 - std::sys_common::backtrace::print::h73765b495122298a
   4:     0x55ffd0b78b37 - std::panicking::default_hook::{{closure}}::hfad133b7877f7d1a
   5:     0x55ffd0b78897 - std::panicking::default_hook::hb7ccbed45ddd154f
   6:     0x55ffd0b790a8 - std::panicking::rust_panic_with_hook::h03308f3977d70e82
   7:     0x55ffd0b78f8a - std::panicking::begin_panic_handler::{{closure}}::h6543c8dd74f459e9
   8:     0x55ffd0b78426 - std::sys_common::backtrace::__rust_end_short_backtrace::h68617e661e847078
   9:     0x55ffd0b78cd4 - rust_begin_unwind
  10:     0x55ffd093eed5 - core::panicking::panic_fmt::hf7f647d933c4266a
  11:     0x55ffd093f3d3 - core::result::unwrap_failed::hea2b65c1fd5e91f1
  12:     0x55ffd0ba36d4 - alloc::fmt::format::format_inner::ha1568917e758aab8
  13:     0x55ffd09805d5 - satty::sketch_board::SketchBoard::handle_save::h417eb56f1dd71caa
  14:     0x55ffd097ad3c - relm4::component::sync::traits::Component::update_with_view::h5546ca99f7ac76a3
  15:     0x55ffd0975111 - glib::main_context_futures::<impl glib::auto::main_context::MainContext>::spawn_local_with_priority::{{closure}}::hfd8f7136142985a0
  16:     0x55ffd0b58afc - glib::main_context::<impl glib::auto::main_context::MainContext>::with_thread_default::h6bed4c0c88c66c19
  17:     0x55ffd0b5a1c1 - glib::main_context_futures::TaskSource::dispatch::hbc8df956068d4d35
  18:     0x7efde8bdd744 - g_main_dispatch
  19:     0x7efde8be0797 - g_main_context_iterate_unlocked.isra.0
  20:     0x7efde8be0d8c - g_main_context_iteration
  21:     0x7efde8db48ad - g_application_run
  22:     0x55ffd09aee05 - gio::application::ApplicationExtManual::run_with_args::h1d5754e006e528f9
  23:     0x55ffd09677f4 - relm4::app::RelmApp<M>::run::hd2a05b8d951b64b5
  24:     0x55ffd09e588b - satty::main::h15bea21168aba68e
  25:     0x55ffd09c0fe3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h546c285c66f04229
  26:     0x55ffd096a57d - std::rt::lang_start::{{closure}}::h9598a22ee5b7e0df
  27:     0x55ffd0b78bd4 - std::panicking::try::hbc3e77d512204ae2
  28:     0x55ffd0b692cb - std::rt::lang_start_internal::hf04efd76000e5213
  29:     0x55ffd09ea415 - main
  30:     0x7efde88b810e - __libc_start_call_main
  31:     0x7efde88b81c9 - __libc_start_main@@GLIBC_2.34
  32:     0x55ffd093f7e5 - _start
  33:                0x0 - <unknown>

Please let me know if there are any reproduction issues—I'm not sure if the formatting is supposed to be used in this way, but even if it isn't, a hang and eventual crash is not great.

If it ends up being relevant, I'm using river and the command is running inside fish. I expect this would reproduce under other circumstances but I haven't tried it.

gabm commented 1 week ago

interesting, thats indeed a bug and shouldn't happen...