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

SEGFAULT crash #1835

Open
AllanDaemon opened this issue Sep 7, 2024 · 10 comments
Open

SEGFAULT crash #1835

AllanDaemon opened this issue Sep 7, 2024 · 10 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@AllanDaemon
Copy link

Bug description

My code is crashing with a segfault.

Maybe related to #1807.

Backtrace

$ RUST_BACKTRACE=full cargo run
   Compiling uchoose v0.5.0 (/data/code/uchoose/uchoose-rs)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.62s
     Running `target/debug/uchoose`
        UI: GTK
        URL: http://example.com/this/is.a.url?all=right
GTK4 Open: http://example.com/this/is.a.url?all=right
App create
App activate
App build
[1]    603971 segmentation fault (core dumped)  RUST_BACKTRACE=full cargo run

The project is in this repository on the gtk-crash branch where I removed a little of the noise (like the old Python implementation).

https://github.com/AllanDaemon/uchoose/tree/gtk-crash

To reproduce, just run cargo run

The crash happens in the file src/ui/ui_gtk4.rs in the method build_uchoose() called by choose().

I'm not using the app.connect_activate() method but calling the build_uchoose() directly;

In the start of the function, it create a gtk::Box::builder(). It crashes with a SEGFAULT when call the .build() method.

IDK if I'm doing something wrong, but a SEGFAULT is not the way to go. That's why I think it's related with the #1807 issue.

@AllanDaemon AllanDaemon added the bug Something isn't working label Sep 7, 2024
@sdroege
Copy link
Member

sdroege commented Sep 16, 2024

This doesn't segfault here. Can you run in a debugger and get a full backtrace, and also provide anything that might be printed on stdout/stderr before that?

@AllanDaemon
Copy link
Author

This doesn't segfault here. Can you run in a debugger and get a full backtrace, and also provide anything that might be printed on stdout/stderr before that?

I think I can, I just don't know how with Rust. Is there any page with a guide or any orientation on how I should do it?

@bilelmoussaoui
Copy link
Member

cargo build
gdb ./target/debug/$your-binary
run
bt full

@AllanDaemon
Copy link
Author

The things printed are only my own debug println!() calls.

image

The backtrack:

$ gdb target/debug/uchoose
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from target/debug/uchoose...
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /data/code/uchoose-butreport/target/debug/uchoose.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) run
Starting program: /data/code/uchoose-butreport/target/debug/uchoose 
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libgobject-2.0.so.0
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libglib-2.0.so.0
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libgmodule-2.0.so.0
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libbrotlidec.so.1
warning: could not find '.gnu_debugaltlink' file for /lib/x86_64-linux-gnu/libbrotlicommon.so.1
        UI: GTK
        URL: http://example.com/this/is.a.url?all=right
GTK4 Open: http://example.com/this/is.a.url?all=right
App create
App build

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff76e24c5 in ?? () from /lib/x86_64-linux-gnu/libgtk-4.so.1
(gdb) bt
#0  0x00007ffff76e24c5 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#1  0x00007ffff76f5673 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#2  0x00007ffff76f6819 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#3  0x00007ffff76f6961 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#4  0x00007ffff76df607 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#5  0x00007ffff7040fbb in g_type_create_instance () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x00007ffff7026a64 in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x00007ffff7028016 in g_object_new_with_properties () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x00007ffff7028f71 in g_object_new () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x00007ffff7688ef4 in ??? () at /lib/x86_64-linux-gnu/libgtk-4.so.1
#10 0x00007ffff7040fbb in g_type_create_instance () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#11 0x00007ffff7026a64 in ??? () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#12 0x00007ffff7028016 in g_object_new_with_properties () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#13 0x000055555569439e in glib::object::Object::new_internal (type_=..., properties=...) at src/object.rs:1491
#14 0x0000555555693940 in glib::object::Object::with_mut_values (type_=..., properties=...) at src/object.rs:1426
#15 0x000055555568a17c in glib::object::ObjectBuilder<gtk4::auto::box_::Box>::build<gtk4::auto::box_::Box> (self=...)
    at /home/rea/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glib-0.20.2/src/object.rs:1635
#16 0x0000555555688e9b in gtk4::auto::box_::BoxBuilder::build (self=...) at src/auto/box_.rs:289
#17 0x00005555555d7e89 in uchoose::ui::ui_gtk4::UchooseWin::build_uchoose (self=0x7fffffffce78, app=0x7fffffffc6c8) at src/ui/ui_gtk4.rs:55
#18 0x00005555555d7ba3 in uchoose::ui::ui_gtk4::UchooseWin::choose (self=0x7fffffffce78) at src/ui/ui_gtk4.rs:42
#19 0x00005555555d8602 in uchoose::ui::ui_gtk4::chooser (url=..., browser_list=0x7fffffffcfc0, default_option=0) at src/ui/ui_gtk4.rs:116
#20 0x00005555555a96b4 in uchoose::execution::choose_and_execute
    (chooser=0x5555555d8470 <uchoose::ui::ui_gtk4::chooser>, url=..., default_option=0) at src/execution.rs:18
#21 0x000055555559de79 in uchoose::main () at src/main.rs:120

Is this enough?

@AllanDaemon
Copy link
Author

Using export DEBUGINFOD_URLS="https://debuginfod.ubuntu.com" before runing gdb, and on gdb set debuginfod enabled on I got a probably better traceback:

gdb target/debug/uchoose
GNU gdb (Ubuntu 15.0.50.20240403-0ubuntu1) 15.0.50.20240403-git
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from target/debug/uchoose...
warning: Missing auto-load script at offset 0 in section .debug_gdb_scripts
of file /data/code/uchoose-butreport/target/debug/uchoose.
Use `info auto-load python-scripts [REGEXP]' to list them.
(gdb) run
Starting program: /data/code/uchoose-butreport/target/debug/uchoose 

This GDB supports auto-downloading debuginfo from the following URLs:
  <https://debuginfod.ubuntu.com>
Enable debuginfod for this session? (y or [n]) y
Debuginfod has been enabled.
To make this setting permanent, add 'set debuginfod enabled on' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
        UI: GTK
        URL: http://example.com/this/is.a.url?all=right
GTK4 Open: http://example.com/this/is.a.url?all=right
App create
App build

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff76e24c5 in gtk_style_provider_get_settings (provider=0x0) at ../../../gtk/gtkstyleprovider.c:137
137       iface = GTK_STYLE_PROVIDER_GET_INTERFACE (provider);
(gdb) bt
#0  0x00007ffff76e24c5 in gtk_style_provider_get_settings (provider=0x0) at ../../../gtk/gtkstyleprovider.c:137
#1  gtk_css_value_initial_compute
    (value=<optimized out>, property_id=1, provider=0x0, style=0x55555596d1d0 [GtkCssStaticStyle], parent_style=0x0)
    at ../../../gtk/gtkcssinitialvalue.c:52
#2  0x00007ffff76f5673 in _gtk_css_initial_value_new_compute
    (parent_style=<optimized out>, style=0x55555596d1d0 [GtkCssStaticStyle], provider=0x0, property_id=1)
    at ../../../gtk/gtkcssinitialvalue.c:134
#3  gtk_css_static_style_compute_value
    (style=style@entry=0x55555596d1d0 [GtkCssStaticStyle], provider=provider@entry=0x0, parent_style=parent_style@entry=0x0, id=1, specified=0x0, section=0x0) at ../../../gtk/gtkcssstaticstyle.c:1097
#4  0x00007ffff76f6819 in gtk_css_core_values_new_compute
    (lookup=0x7fffffff7a60, parent_style=0x0, provider=0x0, sstyle=0x55555596d1d0 [GtkCssStaticStyle]) at ../../../gtk/gtkcssstaticstyle.c:245
#5  gtk_css_lookup_resolve (parent_style=<optimized out>, sstyle=0x55555596d1d0 [GtkCssStaticStyle], provider=0x0, lookup=0x7fffffff7a60)
    at ../../../gtk/gtkcssstaticstyle.c:934
#6  gtk_css_static_style_new_compute
    (provider=provider@entry=0x0, filter=filter@entry=0x7fffffff8070, node=node@entry=0x0, change=<optimized out>, change@entry=0)
    at ../../../gtk/gtkcssstaticstyle.c:1026
#7  0x00007ffff76f6961 in gtk_css_static_style_get_default () at ../../../gtk/gtkcssstaticstyle.c:711
#8  0x00007ffff76df607 in gtk_css_node_init (cssnode=0x55555596e5a0 [GtkCssNode]) at ../../../gtk/gtkcssnode.c:616
#9  0x00007ffff7040fbb in g_type_create_instance (type=<optimized out>) at ../../../gobject/gtype.c:1945
#10 0x00007ffff7026a64 in g_object_new_internal (class=0x55555596e4c0, params=0x0, n_params=0) at ../../../gobject/gobject.c:2603
#11 0x00007ffff7028016 in g_object_new_internal (n_params=<optimized out>, params=<optimized out>, class=<optimized out>)
    at ../../../gobject/gobject.c:2600
#12 g_object_new_with_properties (object_type=<optimized out>, n_properties=<optimized out>, names=names@entry=0x0, values=values@entry=0x0)
    at ../../../gobject/gobject.c:2766
#13 0x00007ffff7028f71 in g_object_new (object_type=<optimized out>, first_property_name=first_property_name@entry=0x0)
    at ../../../gobject/gobject.c:2412
#14 0x00007ffff7688ef4 in gtk_css_widget_node_new (widget=0x55555595a9d0 [GtkWidget]) at ../../../gtk/gtkcsswidgetnode.c:160
#15 gtk_widget_init (instance=0x55555595a9d0 [GtkWidget], g_class=0x555555959560) at ../../../gtk/gtkwidget.c:2368
#16 0x00007ffff7040fbb in g_type_create_instance (type=<optimized out>) at ../../../gobject/gtype.c:1945
#17 0x00007ffff7026a64 in g_object_new_internal (class=0x555555959560, params=0x0, n_params=0) at ../../../gobject/gobject.c:2603
#18 0x00007ffff7028016 in g_object_new_internal (n_params=<optimized out>, params=<optimized out>, class=<optimized out>)
    at ../../../gobject/gobject.c:2600
#19 g_object_new_with_properties (object_type=<optimized out>, n_properties=<optimized out>, names=<optimized out>, values=<optimized out>)
    at ../../../gobject/gobject.c:2766
#20 0x000055555569439e in glib::object::Object::new_internal (type_=..., properties=...) at src/object.rs:1491
#21 0x0000555555693940 in glib::object::Object::with_mut_values (type_=..., properties=...) at src/object.rs:1426
#22 0x000055555568a17c in glib::object::ObjectBuilder<gtk4::auto::box_::Box>::build<gtk4::auto::box_::Box> (self=...)
    at /home/rea/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glib-0.20.2/src/object.rs:1635
#23 0x0000555555688e9b in gtk4::auto::box_::BoxBuilder::build (self=...) at src/auto/box_.rs:289
#24 0x00005555555d7e89 in uchoose::ui::ui_gtk4::UchooseWin::build_uchoose (self=0x7fffffffce48, app=0x7fffffffc698) at src/ui/ui_gtk4.rs:55
#25 0x00005555555d7ba3 in uchoose::ui::ui_gtk4::UchooseWin::choose (self=0x7fffffffce48) at src/ui/ui_gtk4.rs:42
#26 0x00005555555d8602 in uchoose::ui::ui_gtk4::chooser (url=..., browser_list=0x7fffffffcf90, default_option=0) at src/ui/ui_gtk4.rs:116
#27 0x00005555555a96b4 in uchoose::execution::choose_and_execute
    (chooser=0x5555555d8470 <uchoose::ui::ui_gtk4::chooser>, url=..., default_option=0) at src/execution.rs:18
#28 0x000055555559de79 in uchoose::main () at src/main.rs:120

image
image

@sdroege
Copy link
Member

sdroege commented Sep 23, 2024

Does this also happen if you select adwaita as theme? I remember seeing a similar crash before, which was caused by Ubuntu's theme.

@AllanDaemon
Copy link
Author

Does this also happen if you select adwaita as theme? I remember seeing a similar crash before, which was caused by Ubuntu's theme.

I'm not sure. I don't do anything related to theming in the app. I don't even have this theme installed I think. I tried running after export GTK_THEME=adwaita but it crashes the same.

@bilelmoussaoui
Copy link
Member

This looks like either a distro issue or a gtk issue, I would try to reproduce it using some simple python example and report it there.

Nothing to do with the bindings.

@bilelmoussaoui bilelmoussaoui added the invalid This doesn't seem right label Oct 17, 2024
@AllanDaemon
Copy link
Author

I would try to reproduce it using some simple Python example and report it there.

The crashing example is a port of a Python app to Rust. In Python, it works fine and I never have any crashes. The issue happened when I ported it to Rust using gtk4-rs.

I'm using Debian / Ubuntu. If it's a distro problem, could you point out how the appropriate bug report can be opened?

What were the results of trying to reproduce the example given in the OP?

@bilelmoussaoui
Copy link
Member

This looks like a CSS issue to me. As mentioned above by @sdroege, have you tried to run it with the default css theme?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants