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

[bug] Adding a Menu with items to tauri::Builder in Linux crashes with stack overflow #5940

Closed
canadaduane opened this issue Dec 29, 2022 · 10 comments · Fixed by #7535
Closed
Labels
status: needs more info Issue needs more information, discussion or reproducible example status: needs triage This issue needs to triage, applied to new issues type: bug

Comments

@canadaduane
Copy link

canadaduane commented Dec 29, 2022

Describe the bug

When running a demo app with a menu that has at least one item, Tauri crashes with the following error:

thread 'main' has overflowed its stack
fatal runtime error: stack overflow

Here is how I bumped in to this issue. Note that removing .add_native_item(...) will compile and run OK.

use tauri::{Menu, MenuItem};

fn main() {
    let menu = Menu::new().add_native_item(MenuItem::Quit);

    tauri::Builder::default()
        .menu(menu)
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Here is a demo app with a commit that demonstrates the issue:

https://github.com/canadaduane/tsgame/tree/57768202f0ae9dcd559b930d6f62663a7e95ab98

Reproduction

  1. Install dependencies
  2. run pnpm tauri dev in Linux

Expected behavior

The app should not crash with stack overflow. A more useful error would be nice, but ideally the Quit option in the menu should be displayed in a running app.

Platform and versions

I'm not sure how to get the platform and versions from the suggested commands:

$ pnpm run tauri info
 ERR_PNPM_NO_SCRIPT  Missing script: tauri

$ cargo tauri info
error: no such command: `tauri`

	Did you mean `miri`?

	View all installed commands with `cargo --list`

Here is manually collected info:

$ cat /etc/lsb-release
DISTRIB_ID=Pop
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Pop!_OS 22.04 LTS"

$ uname -r
6.0.12-76060006-generic

$ rustc --version
rustc 1.66.0 (69f9c33d7 2022-12-12)

$ cargo --version
cargo 1.66.0 (d65d197ad 2022-11-15)

$ grep tauri pnpm-lock.yaml
... '@tauri-apps/cli': 1.2.2

Stack trace

No response

Additional context

I'm just beginning to use Tauri. I started with the tauri + sveltekit page (https://tauri.app/v1/guides/getting-started/setup/sveltekit).

@canadaduane canadaduane added status: needs triage This issue needs to triage, applied to new issues type: bug labels Dec 29, 2022
@amrbashir
Copy link
Member

amrbashir commented Dec 30, 2022

Can't reproduce, the repro worked fine, need more info like a stack trace if possible.

@amrbashir amrbashir added the status: needs more info Issue needs more information, discussion or reproducible example label Dec 30, 2022
@canadaduane
Copy link
Author

How would I produce a stack trace?

@canadaduane
Copy link
Author

Not much of a stack trace, but here is what I'm getting from gdb:

Starting program: /home/duane/tmp/tsgame/src-tauri/target/debug/tsgame 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffec9ff640 (LWP 113962)]
[New Thread 0x7fffe7fff640 (LWP 113963)]
[New Thread 0x7fffe67ff640 (LWP 113964)]
[New Thread 0x7fffe5ffe640 (LWP 113965)]
[New Thread 0x7fffe543b640 (LWP 113966)]
[Thread 0x7fffe543b640 (LWP 113966) exited]
[New Thread 0x7fffe543b640 (LWP 113967)]
[New Thread 0x7fffe4c3a640 (LWP 113968)]
[Thread 0x7fffe543b640 (LWP 113967) exited]
[Thread 0x7fffe4c3a640 (LWP 113968) exited]
[New Thread 0x7fffe4c3a640 (LWP 113969)]
[New Thread 0x7fffe543b640 (LWP 113970)]
[Thread 0x7fffe4c3a640 (LWP 113969) exited]
[Thread 0x7fffe543b640 (LWP 113970) exited]

Thread 1 "tsgame" received signal SIGSEGV, Segmentation fault.
0x00007ffff37923ab in ?? () from /lib/x86_64-linux-gnu/libgtk-3.so.0

@amrbashir
Copy link
Member

amrbashir commented Dec 30, 2022

so the issue might be coming from libgtk-3 but not sure. also what is the output of pnpm tauri info?

@canadaduane
Copy link
Author

canadaduane commented Dec 30, 2022

Ah, pnpm tauri info works (shows results, which is different from pnpm run tauri info which does not--my mistake earlier):

$ pnpm tauri info

Environment
  › OS: Pop!_OS 22.04 X64
  › Node.js: 18.12.1
  › npm: 8.19.2
  › pnpm: 7.16.1
  › yarn: 1.22.19
  › rustup: 1.25.1
  › rustc: 1.66.0
  › cargo: 1.66.0
  › Rust toolchain: stable-x86_64-unknown-linux-gnu 

Packages
  › @tauri-apps/cli [NPM]: 1.2.2
  › @tauri-apps/api [NPM]: Not installed!
  › tauri [RUST]: 1.2.3,
  › tauri-build [RUST]: 1.2.1,
  › tao [RUST]: 0.15.8,
  › wry [RUST]: 0.23.4,

App
  › build-type: bundle
  › CSP: unset
  › distDir: ../build
  › devPath: http://localhost:5173/
  › framework: Svelte
  › bundler: Vite

App directory structure
  ├─ .git
  ├─ .svelte-kit
  ├─ build
  ├─ static
  ├─ src
  ├─ src-tauri
  └─ node_modules

@canadaduane
Copy link
Author

canadaduane commented Dec 30, 2022

I have some more info available after enabling Ubuntu's debuginfod symbols:

Thread 1 "tsgame" received signal SIGSEGV, Segmentation fault.
0x00007ffff37922a2 in gtk_css_node_ensure_style (cssnode=0x555556322400, current_time=current_time@entry=37661683554) at ../../../../gtk/gtkcssnode.c:987
987	../../../../gtk/gtkcssnode.c: Directory not empty.

(Note for anyone else who wants to enable the same: see https://ubuntu.com/server/docs/service-debuginfod)

UPDATE: Looks similar to this report from an app called Transmission built on GTK: https://bugs.launchpad.net/ubuntu/+source/transmission/+bug/1792811

@canadaduane
Copy link
Author

canadaduane commented Dec 30, 2022

FWIW this is the specific libgtk-3 package installed on my system:

libgtk-3-0/jammy-updates,now 3.24.33-1ubuntu2 amd64 [installed,automatic]
  GTK graphical user interface library

UPDATE: The line 987 appears to be just a reference to the gtk_css_node_ensure_style function name, see https://github.com/GNOME/gtk/blob/3.24.33/gtk/gtkcssnode.c#L987

@amrbashir
Copy link
Member

this is really weird, and I can't find anything useful related to the issue nor can I reproduce it, can you try the same app on another Linux machine?

@canadaduane
Copy link
Author

Thank you for looking in to it. Agreed it is weird. I will try to run on a docker container or within a virtual machine at some point (I'm having trouble getting it set up at the moment).

I tried bt full ("show full backtrace") in gdb and have some new head scratching:

#7986 0x00007ffff3e79c26 in _g_closure_invoke_va (param_types=0x5555560cc530, n_params=3, args=0x7fffff863c10, instance=0x5555560c8900, return_value=<optimized out>, closure=<optimized out>) at ../../../gobject/gclosure.c:893
        marshal = <optimized out>
        marshal_data = <optimized out>
        in_marshal = 1
        real_closure = <optimized out>
        return_accu = <optimized out>
        accu = {g_type = 0x0, data = {{v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        accumulator = 0x0
        emission = Python Exception <class 'TypeError'>: can only concatenate str (not "NoneType") to str
{next = 0x7fffff863df0, instance = 0x5555560c8900, ihint = {signal_id = 209, detail = 0, run_type = (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACCUMULATOR_FIRST_RUN)}, state = EMISSION_RUN, chain_type = }
        instance_type = <optimized out>
        emission_return = {g_type = 0x0, data = {{v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        rtype = 0x4 [None]
        static_scope = 0
        fastpath_handler = <optimized out>
        closure = <optimized out>
        run_type = <optimized out>
        hlist = <optimized out>
        l = <optimized out>
        fastpath = 1
        instance_and_params = <optimized out>
        signal_return_type = <optimized out>
        param_values = <optimized out>
        node = <optimized out>
        i = <optimized out>
        n_params = <optimized out>
        __func__ = "g_signal_emit_valist"
#7987 g_signal_emit_valist (instance=0x5555560c8900, signal_id=209, detail=<optimized out>, var_args=var_args@entry=0x7fffff863c10) at ../../../gobject/gsignal.c:3440
        return_accu = <optimized out>
        accu = {g_type = 0x0, data = {{v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        accumulator = 0x0
        emission = Python Exception <class 'TypeError'>: can only concatenate str (not "NoneType") to str
{next = 0x7fffff863df0, instance = 0x5555560c8900, ihint = {signal_id = 209, detail = 0, run_type = (G_SIGNAL_RUN_FIRST | G_SIGNAL_ACCUMULATOR_FIRST_RUN)}, state = EMISSION_RUN, chain_type = }
        instance_type = <optimized out>
        emission_return = {g_type = 0x0, data = {{v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}, {v_int = 0, v_uint = 0, v_long = 0, v_ulong = 0, v_int64 = 0, v_uint64 = 0, v_float = 0, v_double = 0, v_pointer = 0x0}}}
        rtype = 0x4 [None]
        static_scope = 0
        fastpath_handler = <optimized out>
        closure = <optimized out>
        run_type = <optimized out>
        hlist = <optimized out>
        l = <optimized out>
        fastpath = 1
        instance_and_params = <optimized out>
        signal_return_type = <optimized out>
        param_values = <optimized out>
        node = <optimized out>
        i = <optimized out>
        n_params = <optimized out>
        __func__ = "g_signal_emit_valist"
#7988 0x00007ffff3e7a863 in g_signal_emit (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../../../gobject/gsignal.c:3587
        var_args = {{gp_offset = 24, fp_offset = 48, overflow_arg_area = 0x7fffff863cf0, reg_save_area = 0x7fffff863c30}}
#7992 0x00007ffff3e7a863 in <emit signal ??? on instance ???> (instance=<optimized out>, signal_id=<optimized out>, detail=<optimized out>) at ../../../gobject/gsignal.c:3587
        var_args = {{gp_offset = 40, fp_offset = 48, overflow_arg_area = 0x7fffff864140, reg_save_area = 0x7fffff864080}}

This is repeated over and over again (we're in the 7000s here). What could Python Exception <class 'TypeError'>: can only concatenate str (not "NoneType") to str be related to? Is an error message triggering an error message perhaps? Why is Python involved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs more info Issue needs more information, discussion or reproducible example status: needs triage This issue needs to triage, applied to new issues type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants