mitchmindtree / blackbox.nix

A nix flake for Paulo Queiroz' beautiful GTK 4 Terminal.
MIT License
5 stars 1 forks source link

When running, often crashes with `GLib:ERROR` `g_variant_type_info_check: assertion failed: (0 <= index && index < 24)` #2

Open mitchmindtree opened 2 years ago

mitchmindtree commented 2 years ago

This flake worked once and appeared to run smoothly with nix run, however all following runs have resulted in immediately erroring with:

GLib:ERROR:../glib/gvarianttypeinfo.c:186:g_variant_type_info_check: assertion failed: (0 <= index && index < 24)
Bail out! GLib:ERROR:../glib/gvarianttypeinfo.c:186:g_variant_type_info_check: assertion failed: (0 <= index && index < 24)

Not sure what's going on here yet.

mitchmindtree commented 2 years ago

So it turns out I must have just been "lucky" the first time it ran. If I simply repeatedly try to run the program, it appears to "work" about 1 in 20 times - the terminal opens, I can configure styling, etc.

Here's a tmux shell running inside it:

Screenshot from 2022-06-18 12-08-52

The vast majority of the time when starting up, I get the errors in the OP, often followed by Aborted (core dumped).

jtojnar commented 2 years ago

You need to get full stack trace. Try rebuilding the packages with dontStrip = true;. Then run the program until it crashes and obtain the stack trace with coredumpctl (see e.g. https://discourse.nixos.org/t/how-to-investigate-gnome-crashing/19726/2)

mitchmindtree commented 2 years ago

Thanks for the tip @jtojnar!

I've added dontStrip = true;, then had a go at grabbing the stacktrace with gdb by catching the signal and printing the backtrace as follows:

(gdb) catch signal
Catchpoint 1 (standard signals)
(gdb) catch signal SIGABRT
Catchpoint 2 (signal SIGABRT)
(gdb) run                                                                                                                                                                                   
Starting program: /nix/store/y0w430rg6zjwfm9ryxx4jcwgi1khxqzg-blackbox-main/bin/blackbox 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/nix/store/m4g6lswi75b739cpdx8wfxlfmcazyks9-glibc-2.34-115/lib/libthread_db.so.1".
process 1119638 is executing new program: /nix/store/y0w430rg6zjwfm9ryxx4jcwgi1khxqzg-blackbox-main/bin/.blackbox-wrapped_
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/nix/store/m4g6lswi75b739cpdx8wfxlfmcazyks9-glibc-2.34-115/lib/libthread_db.so.1".
process 1119638 is executing new program: /nix/store/y0w430rg6zjwfm9ryxx4jcwgi1khxqzg-blackbox-main/bin/.blackbox-wrapped
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/nix/store/m4g6lswi75b739cpdx8wfxlfmcazyks9-glibc-2.34-115/lib/libthread_db.so.1".
process 1119638 is executing new program: /nix/store/y0w430rg6zjwfm9ryxx4jcwgi1khxqzg-blackbox-main/bin/..blackbox-wrapped-wrapped
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/nix/store/m4g6lswi75b739cpdx8wfxlfmcazyks9-glibc-2.34-115/lib/libthread_db.so.1".
warning: File "/nix/store/8dn12i3d7harw8g7dzk6dy7c5diz5ibp-gcc-11.3.0-lib/lib/libstdc++.so.6.0.29-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load:/nix/store/69brclzxp7mg927k6986hrfzyd1hpqgd-gcc-11.2.0-lib".
To enable execution of this file add
        add-auto-load-safe-path /nix/store/8dn12i3d7harw8g7dzk6dy7c5diz5ibp-gcc-11.3.0-lib/lib/libstdc++.so.6.0.29-gdb.py
line to your configuration file "/home/mindtree/.config/gdb/gdbinit".
To completely disable this security protection add
        set auto-load safe-path /
line to your configuration file "/home/mindtree/.config/gdb/gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual.  E.g., run from the shell:
        info "(gdb)Auto-loading safe path"
[New Thread 0x7fffe4d00640 (LWP 1119642)]
[New Thread 0x7fffdffff640 (LWP 1119643)]
[New Thread 0x7fffdf7fe640 (LWP 1119644)]
[New Thread 0x7fffdeffd640 (LWP 1119645)]
[New Thread 0x7fffde7fc640 (LWP 1119646)]
[Thread 0x7fffdf7fe640 (LWP 1119644) exited]
**
GLib:ERROR:../glib/gvarianttypeinfo.c:186:g_variant_type_info_check: assertion failed: (0 <= index && index < 24)
Bail out! GLib:ERROR:../glib/gvarianttypeinfo.c:186:g_variant_type_info_check: assertion failed: (0 <= index && index < 24)

Thread 1 "..blackbox-wrap" hit Catchpoint 1 (signal SIGABRT), 0x00007ffff62d2c1f in __pthread_kill_implementation () from /nix/store/fz33c1mfi2krpg1lwzizfw28kj705yg0-glibc-2.34-210/lib/libc.so.6
(gdb) bt
#0  0x00007ffff62d2c1f in __pthread_kill_implementation () from /nix/store/fz33c1mfi2krpg1lwzizfw28kj705yg0-glibc-2.34-210/lib/libc.so.6
#1  0x00007ffff6288042 in raise () from /nix/store/fz33c1mfi2krpg1lwzizfw28kj705yg0-glibc-2.34-210/lib/libc.so.6
#2  0x00007ffff627349c in abort () from /nix/store/fz33c1mfi2krpg1lwzizfw28kj705yg0-glibc-2.34-210/lib/libc.so.6
#3  0x00007ffff7c69ddc in g_assertion_message.cold () from /nix/store/ckj0g3ycva2an405zf4mh4bvqhj44zr5-glib-2.72.1/lib/libglib-2.0.so.0
#4  0x00007ffff7cc977b in g_assertion_message_expr () from /nix/store/ckj0g3ycva2an405zf4mh4bvqhj44zr5-glib-2.72.1/lib/libglib-2.0.so.0
#5  0x00007ffff7ceca06 in g_variant_type_info_check () from /nix/store/ckj0g3ycva2an405zf4mh4bvqhj44zr5-glib-2.72.1/lib/libglib-2.0.so.0
#6  0x00007ffff7ceca7b in g_variant_type_info_get_type_string () from /nix/store/ckj0g3ycva2an405zf4mh4bvqhj44zr5-glib-2.72.1/lib/libglib-2.0.so.0
#7  0x00007ffff7ce2e34 in g_variant_check_format_string () from /nix/store/ckj0g3ycva2an405zf4mh4bvqhj44zr5-glib-2.72.1/lib/libglib-2.0.so.0
#8  0x000000000041112a in terminal_padding_from_variant ()
#9  0x00000000004145f5 in terminal_settings_get_padding ()
#10 0x000000000040b633 in terminal_terminal_on_padding_changed ()
#11 0x000000000040c394 in terminal_terminal_construct ()
#12 0x000000000040e19c in terminal_terminal_tab_construct ()
#13 0x000000000041134a in terminal_window_new_tab ()
#14 0x0000000000411c88 in terminal_window_construct ()
#15 0x00000000004097da in terminal_application_real_activate ()
#16 0x00007ffff7d99849 in _g_closure_invoke_va () from /nix/store/ckj0g3ycva2an405zf4mh4bvqhj44zr5-glib-2.72.1/lib/libgobject-2.0.so.0
#17 0x00007ffff7db2153 in g_signal_emit_valist () from /nix/store/ckj0g3ycva2an405zf4mh4bvqhj44zr5-glib-2.72.1/lib/libgobject-2.0.so.0
#18 0x00007ffff7db241f in g_signal_emit () from /nix/store/ckj0g3ycva2an405zf4mh4bvqhj44zr5-glib-2.72.1/lib/libgobject-2.0.so.0
#19 0x00007ffff7ec43a8 in g_application_real_local_command_line () from /nix/store/ckj0g3ycva2an405zf4mh4bvqhj44zr5-glib-2.72.1/lib/libgio-2.0.so.0
#20 0x00007ffff7ec451e in g_application_run () from /nix/store/ckj0g3ycva2an405zf4mh4bvqhj44zr5-glib-2.72.1/lib/libgio-2.0.so.0
#21 0x0000000000409593 in main ()

Here's a little more info via coredumpctl gdb <pid>:

coredumpctl-gdb-blackbox.txt

jtojnar commented 2 years ago

That looks like a blackbox bug then. Try updating it and if it does not help, report it upstream.

jtojnar commented 2 years ago

Apparently, you also need to pass mesonBuildType = "debug"; for the debug symbols.

yilozt commented 2 years ago

I met same problem when I try to create PKGBUILD in Arch Linux, too. Blackbox can be opened in first time, but after changed default settings in preferences, Blackbox crash when I try to open it in next time.

I fix it with this simple patch:

diff --git a/src/widgets/Terminal.vala b/src/widgets/Terminal.vala
index 65b0042..6b52854 100644
--- a/src/widgets/Terminal.vala
+++ b/src/widgets/Terminal.vala
@@ -72,7 +72,7 @@ public class Terminal.Terminal : Vte.Terminal {
     this.connect_accels ();
     this.on_theme_changed ();
     this.on_font_changed ();
-    this.on_padding_changed ();
+    this.settings.terminal_padding = this.settings.schema.get_value ("terminal-padding");

     this.spawn (command, cwd);
   }

I don't know whether it should be report to upstream, because it run well and don't crash in flatpak. May be this bug is relate to the version of GLib.

raggesilver commented 2 years ago

Hi @mitchmindtree, thanks for investigating this issue, and thank you, @yilozt, for trying to fix it. I usually don't provide support to other forms of packaging my apps, but this crash got my attention. I looked at the C code the Vala compiler created, and oh boy... it's awful. Could you re-compile with this patch?

diff --git a/src/widgets/Window.vala b/src/widgets/Window.vala
index b0d6400..b514230 100644
--- a/src/widgets/Window.vala
+++ b/src/widgets/Window.vala
@@ -36,13 +36,12 @@ public struct Terminal.Padding {
     return { 0 };
   }

-  public static Padding from_variant (Variant vari) {
-    return_val_if_fail (
-      vari.check_format_string ("(uuuu)", false),
-      Padding.zero ()
-    );
+  public static Padding from_variant (Variant variant) {
+    if (!variant.check_format_string ("(uuuu)", false)) {
+      return Padding.zero ();
+    }

-    var iter = vari.iterator ();
+    var iter = variant.iterator ();
     uint top = 0, right = 0, bottom = 0, left = 0;

     iter.next ("u", &top);

If it doesn't work, could you share the output of the following command? gsettings get com.raggesilver.BlackBox terminal-padding

mitchmindtree commented 2 years ago

@raggesilver thanks for dropping by and having a go at addressing this! Unfortunately no luck with that patch, I'm still seeing the same behaviour. You can find the branch here, which you can run yourself directly with:

nix run github:mitchmindtree/blackbox.nix/terminal-from-variant-patch

If it doesn't work, could you share the output of the following command? gsettings get com.raggesilver.BlackBox terminal-padding

Hmmm no luck calling that command as it is. I get No such schema “com.raggesilver.BlackBox”.

However, if I pass the schemas directory of BlackBox directly like so:

gsettings --schemadir /nix/store/107cmx5ad4ma598vazmp0xrj0c0s4z3y-blackbox-main/share/gsettings-schemas/blackbox-main/glib-2.0/schemas get com.raggesilver.BlackBox terminal-padding

I get:

(uint32 20, uint32 20, uint32 20, uint32 20)

Does that help at all?


@yilozt your patch appears to work nicely! I've pushed a branch with it here. You can test it with:

nix run github:mitchmindtree/blackbox.nix/yilozt-launch-fix

Perhaps if we can't work out a proper solution, we can fallback to merging this into main as a temp workaround.

yilozt commented 2 years ago

@raggesilver , Sorry that I have apply this patch but it still emit this bug. This is my screen recording and log:

https://user-images.githubusercontent.com/32430186/174615892-a22c725a-082d-4948-ad37-8b214abf22ab.mov

截图 2022-06-20 20-59-13

# Arch Linux
# Kernel: 5.18.4-xanmod1-1
# Gnome-shell: GNOME Shell 42.2
# Gtk4: 4.6.5-1
# Glib: 2.72.2-1

# After reset settings, blackbox can be launched.
luo@luo ~> gsettings reset-recursively  com.raggesilver.BlackBox

# Launch then change paddings
luo@luo ~> blackbox

(blackbox:1228610): GLib-CRITICAL **: 21:23:32.592: g_variant_ref_sink: assertion '!g_atomic_ref_count_compare (&value->ref_count, 0)' failed

(blackbox:1228610): GLib-CRITICAL **: 21:23:32.592: g_atomic_ref_count_dec: assertion 'old_value > 0' failed

(blackbox:1228610): Gtk-CRITICAL **: 21:23:39.884: gtk_widget_grab_focus: assertion 'GTK_IS_WIDGET (widget)' failed

# Close blackbox, then launch again, crash.
luo@luo ~> blackbox
**
GLib:ERROR:../glib/glib/gvarianttypeinfo.c:186:g_variant_type_info_check: assertion failed: (0 <= index && index < 24)
Bail out! GLib:ERROR:../glib/glib/gvarianttypeinfo.c:186:g_variant_type_info_check: assertion failed: (0 <= index && index < 24)
fish: Job 1, 'blackbox' terminated by signal SIGABRT (Abort)

# But paddings has been store into dconf
luo@luo ~ [SIGSEGV]> gsettings get com.raggesilver.BlackBox terminal-padding
(uint32 1, uint32 1, uint32 1, uint32 1)

# Reset settings again, so we can launch blackbox now.
luo@luo ~ [SIGABRT]> gsettings reset-recursively  com.raggesilver.BlackBox

# Launch blackbox but do nothing
luo@luo ~> blackbox
Unsupported modifier, resource creation failed.
XXX: resource creation failed
Unsupported modifier, resource creation failed.
XXX: resource creation failed
Unsupported modifier, resource creation failed.
XXX: resource creation failed

# Close blackbox, then launch again, crash.
luo@luo ~> blackbox
**
GLib:ERROR:../glib/glib/gvarianttypeinfo.c:186:g_variant_type_info_check: assertion failed: (0 <= index && index < 24)
Bail out! GLib:ERROR:../glib/glib/gvarianttypeinfo.c:186:g_variant_type_info_check: assertion failed: (0 <= index && index < 24)
fish: Job 1, 'blackbox' terminated by signal SIGABRT (Abort)

# Paddings is zero because I have not change it.
luo@luo ~ [SIGABRT]> gsettings get com.raggesilver.BlackBox terminal-padding
(uint32 0, uint32 0, uint32 0, uint32 0)
raggesilver commented 2 years ago

Huh, that's interesting. So with padding reset, Black Box will open just fine, but it no longer opens after we load it (and possibly change its value). I'll check if there's any possibility I'm saving some garbage value in terminal-padding.