gtk-rs / gtk4-rs

Rust bindings of GTK 4
https://gtk-rs.org/gtk4-rs/
MIT License
1.9k stars 174 forks source link

[BUG] ` gtk4::FontButton.preview_text` cause crash #901

Open qarmin opened 2 years ago

qarmin commented 2 years ago
System:    Host: rafalkom Kernel: 5.13.0-28-generic x86_64 bits: 64 compiler: gcc v: 11.2.0 Desktop: GNOME 40.5 
           tk: GTK 3.24.30 wm: gnome-shell dm: GDM3 Distro: Ubuntu 21.10 (Impish Indri) 
RUST_BACKTRACE=full RUSTFLAGS=-Zsanitizer=address RUSTDOCFLAGS=-Zsanitizer=address cargo run  -Zbuild-std --target x86_64-unknown-linux-gnu

Bug description

    let object_283 = FontButton::new(); // FontButton
    object_283.preview_text();

cause crash:

thread 'main' panicked at 'assertion failed: !ptr.is_null()', /home/rafal/.cargo/git/checkouts/gtk-rs-core-7be42ca38bd6361c/3167871/glib/src/gstring.rs:321:9
stack backtrace:
   0:     0x55630770bcb5 - std::backtrace_rs::backtrace::libunwind::trace::h724e5bf51b0bdeb8
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55630770bcb5 - std::backtrace_rs::backtrace::trace_unsynchronized::hc82c40a0376ae7d7
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5563075ea97e - std::sys_common::backtrace::_print_fmt::hea603b8559ffc9b1
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x5563075ea0e9 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::he7d66fa55811781f
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x5563079ba385 - core::fmt::write::hb0ec546ccfce83c2
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:1190:17
   5:     0x5563075d7b08 - std::io::Write::write_fmt::h3693478b33b13fd5
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/io/mod.rs:1657:15
   6:     0x5563075e9fe4 - std::sys_common::backtrace::_print::hb480943d44f9ba68
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x5563075e9b4e - std::sys_common::backtrace::print::h2e68a689d2b6e66c
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x556307799ba9 - std::panicking::default_hook::{{closure}}::h883a506ba80935ac
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:295:22
   9:     0x556307798e06 - std::panicking::default_hook::he383a16fd745d86f
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:314:9
  10:     0x55630779f1a1 - std::panicking::rust_panic_with_hook::he55532a23f201724
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:698:17
  11:     0x55630779e732 - std::panicking::begin_panic_handler::{{closure}}::h1c9db301df3acdad
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:586:13
  12:     0x5563075eca9d - std::sys_common::backtrace::__rust_end_short_backtrace::h36cb68a2d331b01d
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:138:18
  13:     0x55630779cfaf - rust_begin_unwind
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:584:5
  14:     0x5563079aa1a6 - core::panicking::panic_fmt::h4457af6eff34ee1a
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:143:14
  15:     0x5563079a9862 - core::panicking::panic::hf9f684f110c4f77c
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/panicking.rs:48:5
  16:     0x55630738fa6f - <glib::gstring::GString as glib::translate::FromGlibPtrFull<*mut u8>>::from_glib_full::h28afa2301bcaf253
                               at /home/rafal/.cargo/git/checkouts/gtk-rs-core-7be42ca38bd6361c/3167871/glib/src/gstring.rs:321:9
  17:     0x55630742def6 - glib::translate::from_glib_full::h092bcf0c285663f0
                               at /home/rafal/.cargo/git/checkouts/gtk-rs-core-7be42ca38bd6361c/3167871/glib/src/translate.rs:1435:5
  18:     0x55630738fc77 - <glib::gstring::GString as glib::translate::FromGlibPtrFull<*mut i8>>::from_glib_full::hcbc978cf6ef91261
                               at /home/rafal/.cargo/git/checkouts/gtk-rs-core-7be42ca38bd6361c/3167871/glib/src/gstring.rs:337:9
  19:     0x55630742e0c6 - glib::translate::from_glib_full::hf08051f19b20ee78
                               at /home/rafal/.cargo/git/checkouts/gtk-rs-core-7be42ca38bd6361c/3167871/glib/src/translate.rs:1435:5
  20:     0x556306f73b38 - <O as gtk4::auto::font_chooser::FontChooserExt>::preview_text::h0af50db2bbf1f40b
                               at /home/rafal/.cargo/git/checkouts/gtk4-rs-e74ad56283dfeb5e/8f08e72/gtk4/src/auto/font_chooser.rs:196:13
  21:     0x556306f7aadd - crash_thing::crashes::hd10bc61ebee97362
                               at /home/rafal/Projekty/Rust/gtk_rs_fuzzer/Project/src/main.rs:38:5
  22:     0x556306f744f8 - crash_thing::main::{{closure}}::h99d270ea5baaa0d1
                               at /home/rafal/Projekty/Rust/gtk_rs_fuzzer/Project/src/main.rs:24:13
  23:     0x556306f73a6b - <O as gio::auto::application::ApplicationExt>::connect_activate::activate_trampoline::h91258cdadfe72d33
                               at /home/rafal/.cargo/git/checkouts/gtk-rs-core-7be42ca38bd6361c/3167871/gio/src/auto/application.rs:604:13
  24:     0x7f2fc9282c0f - g_closure_invoke
  25:     0x7f2fc929eea6 - <unknown>
  26:     0x7f2fc92a0884 - g_signal_emit_valist
  27:     0x7f2fc92a0ad3 - g_signal_emit
  28:     0x7f2fc93a59d8 - <unknown>
  29:     0x7f2fc93a5bb6 - g_application_run
  30:     0x556306f74f59 - <O as gio::application::ApplicationExtManual>::run_with_args::h68786f7d87165c94
                               at /home/rafal/.cargo/git/checkouts/gtk-rs-core-7be42ca38bd6361c/3167871/gio/src/application.rs:30:13
  31:     0x556306f74948 - <O as gio::application::ApplicationExtManual>::run::h2fb226a192c21ca9
                               at /home/rafal/.cargo/git/checkouts/gtk-rs-core-7be42ca38bd6361c/3167871/gio/src/application.rs:23:9
  32:     0x556306f7a6b7 - crash_thing::main::hc51bec7a5b8c7e89
                               at /home/rafal/Projekty/Rust/gtk_rs_fuzzer/Project/src/main.rs:31:5
  33:     0x556306f7c68b - core::ops::function::FnOnce::call_once::h3fd7cdd36c90b094
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227:5
  34:     0x556306f799f5 - std::sys_common::backtrace::__rust_begin_short_backtrace::h43935b03eb4cf297
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:122:18
  35:     0x556306f75b64 - std::rt::lang_start::{{closure}}::h1235bc9d4d9829c5
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:145:18
  36:     0x55630778de8e - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h43e2cfacab1d39a9
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:259:13
  37:     0x55630779bf7f - std::panicking::try::do_call::h7cf1c45ecf74e21c
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:492:40
  38:     0x5563077a512b - __rust_try
  39:     0x55630779a223 - std::panicking::try::h11786f75c5e8f92c
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:456:19
  40:     0x55630754c53a - std::panic::catch_unwind::h4dd0051ef18d6daa
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
  41:     0x5563075e95ac - std::rt::lang_start_internal::{{closure}}::h648b6b8193457c95
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:128:48
  42:     0x55630779bd7e - std::panicking::try::do_call::h13596aff24f38038
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:492:40
  43:     0x5563077a512b - __rust_try
  44:     0x55630779af1c - std::panicking::try::h59f157e493726e21
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panicking.rs:456:19
  45:     0x55630754c85a - std::panic::catch_unwind::hec526b79455e9b90
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/panic.rs:137:14
  46:     0x5563075e8efa - std::rt::lang_start_internal::hc671c8fded5192b3
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:128:20
  47:     0x556306f75ac6 - std::rt::lang_start::h46f1fcb3dbb7346d
                               at /home/rafal/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:144:17
  48:     0x556306f7ad7c - main
  49:     0x7f2fc8e3efd0 - __libc_start_call_main
                               at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  50:     0x7f2fc8e3f07d - __libc_start_main_impl
                               at ./csu/../csu/libc-start.c:409:3
  51:     0x556306ee11e5 - _start
  52:                0x0 - <unknown>

=================================================================

Issue found by fuzzer - https://github.com/qarmin/gtk-rs-fuzzer

bilelmoussaoui commented 2 years ago

Needs nullable annotations upstream