wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.78k stars 796 forks source link

Crash #3614

Closed junkblocker closed 1 year ago

junkblocker commented 1 year ago

What Operating System(s) are you seeing this problem on?

FreeBSD Wayland

Which Wayland compositor or X11 Window manager(s) are you using?

No idea. Fedora 38 KDE/Plasma whatever default compositor it has. I am sure I see the crash with X11 too though.

WezTerm version

wezterm 20230423-174840-5c2e3fe8

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

I have code which changes a single layer background image on keypress. As I cycle through it, it randomly crashes.

To Reproduce

Random

Configuration

no config

Expected Behavior

Should not crash.

Logs

21:59:32.820  ERROR  env_bootstrap > panic at wezterm-gui/src/glyphcache.rs:908:28 - !?
0: <unknown>
1: <unknown>
2: <unknown>
3: <unknown>
4: <unknown>
5: <unknown>
6: <unknown>
7: <unknown>
8: <unknown>
9: <unknown>
10: <unknown>
11: <unknown>
12: <unknown>
13: <unknown>
14: <unknown>
15: <unknown>
16: <unknown>
17: <unknown>
18: <unknown>
19: <unknown>
20: <unknown>
21: <unknown>
22: <unknown>
23: <unknown>
24: <unknown>
25: <unknown>
26: __libc_start_call_main
27: __libc_start_main@@GLIBC_2.34
28: <unknown>

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', wezterm-gui/src/glyphcache.rs:908:28
stack backtrace:
0:     0x55c9b6d1779a - <unknown>
1:     0x55c9b6d4487e - <unknown>
2:     0x55c9b6d11b65 - <unknown>
3:     0x55c9b6d17565 - <unknown>
4:     0x55c9b6d1928f - <unknown>
5:     0x55c9b6d18fcb - <unknown>
6:     0x55c9b549c508 - <unknown>
7:     0x55c9b6d199bd - <unknown>
8:     0x55c9b6d19739 - <unknown>
9:     0x55c9b6d17c06 - <unknown>
10:     0x55c9b6d19442 - <unknown>
11:     0x55c9b4fda523 - <unknown>
12:     0x55c9b4fda692 - <unknown>
13:     0x55c9b522750f - <unknown>
14:     0x55c9b5227a81 - <unknown>
15:     0x55c9b52e864b - <unknown>
16:     0x55c9b52e4513 - <unknown>
17:     0x55c9b52ffbde - <unknown>
18:     0x55c9b50fa07d - <unknown>
19:     0x55c9b5f27df8 - <unknown>
20:     0x55c9b5ef4f28 - <unknown>
21:     0x55c9b5fe608c - <unknown>
22:     0x55c9b5fbc735 - <unknown>
23:     0x55c9b5f93350 - <unknown>
24:     0x55c9b5f265ae - <unknown>
25:     0x55c9b521eb85 - <unknown>
26:     0x55c9b5194bc2 - <unknown>
27:     0x55c9b5195e38 - <unknown>
28:     0x55c9b5115a03 - <unknown>
29:     0x55c9b50cb8d9 - <unknown>
30:     0x55c9b6d0ab9c - <unknown>
31:     0x55c9b519f485 - <unknown>
32:     0x7f8f42048b4a - __libc_start_call_main
33:     0x7f8f42048c0b - __libc_start_main@@GLIBC_2.34
34:     0x55c9b4fdabb5 - <unknown>
35:                0x0 - <unknown>
21:59:32.821  ERROR  env_bootstrap > panic at /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/thread/local.rs:422:26 - !?
0: <unknown>
1: <unknown>
2: <unknown>
3: <unknown>
4: <unknown>
5: <unknown>
6: <unknown>
7: <unknown>
8: <unknown>
9: <unknown>
10: <unknown>
11: <unknown>
12: <unknown>
13: <unknown>
14: <unknown>
15: __call_tls_dtors
16: __run_exit_handlers
17: exit
18: __libc_start_call_main
19: __libc_start_main@@GLIBC_2.34
20: <unknown>

thread 'main' panicked at 'cannot access a Thread Local Storage value during or after destruction: AccessError', /rustc/84c898d65adf2f39a5a98507f1fe0ce10a2b8dbc/library/std/src/thread/local.rs:422:26
stack backtrace:
0:     0x55c9b6d1779a - <unknown>
1:     0x55c9b6d4487e - <unknown>
2:     0x55c9b6d11b65 - <unknown>
3:     0x55c9b6d17565 - <unknown>
4:     0x55c9b6d1928f - <unknown>
5:     0x55c9b6d18fcb - <unknown>
6:     0x55c9b549c508 - <unknown>
7:     0x55c9b6d199bd - <unknown>
8:     0x55c9b6d19739 - <unknown>
9:     0x55c9b6d17c06 - <unknown>
10:     0x55c9b6d19442 - <unknown>
11:     0x55c9b4fda523 - <unknown>
12:     0x55c9b4fda9d3 - <unknown>
13:     0x55c9b5311ba9 - <unknown>
14:     0x55c9b532edf7 - <unknown>
15:     0x55c9b50cf442 - <unknown>
16:     0x55c9b5331f66 - <unknown>
17:     0x55c9b5318191 - <unknown>
18:     0x55c9b5342e44 - <unknown>
19:     0x55c9b532a2fe - <unknown>
20:     0x55c9b503fcd0 - <unknown>
21:     0x7f8f42060e8f - __call_tls_dtors
22:     0x7f8f4206126f - __run_exit_handlers
23:     0x7f8f420612be - exit
24:     0x7f8f42048b51 - __libc_start_call_main
25:     0x7f8f42048c0b - __libc_start_main@@GLIBC_2.34
26:     0x55c9b4fdabb5 - <unknown>
27:                0x0 - <unknown>
warning: queue 0x55c9bade72a0 destroyed while proxies still attached:
wl_display@1 still attached
warning: queue 0x55c9ba81e7e0 destroyed while proxies still attached:
wl_callback@66 still attached
wl_buffer@75 still attached
wl_buffer@68 still attached
wl_buffer@71 still attached
wl_buffer@76 still attached
wl_subsurface@63 still attached
wl_surface@59 still attached
wl_subsurface@80 still attached
wl_surface@81 still attached
wl_subsurface@55 still attached
wl_surface@51 still attached
wl_subsurface@72 still attached
wl_surface@79 still attached
wl_subsurface@73 still attached
wl_surface@78 still attached
wl_buffer@48 still attached
wl_buffer@65 still attached
wl_buffer@52 still attached
wl_buffer@29 still attached
wl_buffer@54 still attached
wl_shm_pool@35 still attached
zwp_primary_selection_offer_v1@4278190082 still attached
wl_data_offer@4278190081 still attached
wl_data_offer@4278190080 still attached
xdg_wm_base@22 still attached
wl_surface@21 still attached
wl_data_device@18 still attached
wl_pointer@16 still attached
zwp_text_input_v3@15 still attached
wl_keyboard@14 still attached
zwp_primary_selection_device_v1@13 still attached
zwp_primary_selection_device_manager_v1@3 still attached
wl_data_device@12 still attached
zwp_text_input_manager_v3@11 still attached
wl_output@10 still attached
wl_subcompositor@9 still attached
wl_data_device_manager@8 still attached
wl_seat@7 still attached
wl_shm@6 still attached
zxdg_decoration_manager_v1@5 still attached
wl_compositor@4 still attached
wl_registry@2 still attached
fatal runtime error: thread local panicked on drop
[1]    613318 IOT instruction (core dumped)  RUST_BACKTRACE=full wezterm                                                                             /17.1s
134:IOT: RUST_BACKTRACE=full wezterm

Anything else?

No response

wez commented 1 year ago

Please include the configuration that you mention that triggers this when you cycle. Please also include the trace inline in this report, not in pastebin.

junkblocker commented 1 year ago

Added trace inline.

wez commented 1 year ago

I have code which changes a single layer background image on keypress. As I cycle through it, it randomly crashes.

Where is the config for this?

wez commented 1 year ago

Is there a specific animated image you are using for this?

junkblocker commented 1 year ago

There are no animated images. There are all jpgs or pngs. The configuration is difficult to extact but I'm just overriding the background. The change code looks like this and trigged by a keypress

function change_wallpaper(window, notused)
    log("change_wallpaper called") -- log is just just wezterm.log_info
    if not wezterm.GLOBAL.ENABLE_WALLPAPER then
        log("change_wallpaper called when wallpapers are not enabled")
        return
    end

    -- set a new one
    local img, brightness = random_wallpaper() -- returns an image path and a float , usually 0.05
    log(img .. " at " .. tostring(brightness) .. " brightness")

    wezterm.GLOBAL.WALLPAPER_LAST_FIDDLED_WITH = os.time()
    -- set a new one
    local overrides = window:get_config_overrides() or {}
    overrides.background = {
        -- This is the deepest/back-most layer. It will be rendered first
        {
            source = {
                File = img,
            },
            -- The texture tiles vertically but not horizontally.
            -- When we repeat it, mirror it so that it appears "more seamless".
            -- An alternative to this is to set `width = "100%"` and have
            -- it stretch across the display
            repeat_x = 'NoRepeat',
            hsb = { brightness = brightness },
            -- When the viewport scrolls, move this layer 10% of the number of
            -- pixels moved by the main viewport. This makes it appear to be
            -- further behind the text.
            attachment = "Fixed",
            horizontal_align = 'Center',
            vertical_align = 'Middle',
            horizontal_offset = 0,
            vertical_offset = 0,
            height = "Cover",
        },
    }
    window:set_config_overrides(overrides)
    wezterm.background_child_process({ "wpaper", img })                         -- a script that sets desktop wallpaper
    wezterm.background_child_process({ "konsole-wpaper", img })          -- a script that copies the image setting over to konsole config
end
wez commented 1 year ago

The line of code mentioned in your panic is in the middle of handling frames from an animated image source. Note that PNGs can be animated. Can you figure out which of your backgrounds might be the source of this and share it?

Alternatively, are you running something that uses the kitty image protocol to send multiple frames of images?

junkblocker commented 1 year ago

Ah, I seem to have some WebP images and it is crashing on those. It still looks to be a single frame but even Okular is having trouble opening it. sxiv/nsxiv/qimgv open these ok. Github won't let me attach one here. Even imgur is failing to allow upload of that.

junkblocker commented 1 year ago

2995f0_9dfad96b40ce4fc9a63a1c2341f1a94d~mv2-3840x2160.zip

wez commented 1 year ago

This should be resolved now in main.

It typically takes about an hour before commits are available as nightly builds for all platforms. Linux builds are the fastest to build and are often available within about 20 minutes. Windows and macOS builds take a bit longer.

Please take a few moments to try out the fix and let me know how that works out. You can find the nightly downloads for your system in the wezterm installation docs.

If you prefer to use packages provided by your distribution or package manager of choice and don't want to replace that with a nightly download, keep in mind that you can download portable packages (eg: a .dmg file on macOS, a .zip file on Windows and an .AppImage file on Linux) that can be run without permanently installing or replacing an existing package, and can then simply be deleted once you no longer need them.

If you are eager and can build from source then you may be able to try this out more quickly.

junkblocker commented 1 year ago

Yep, it is fixed. Thanks!

github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.