GeopJr / Tuba

Browse the Fediverse
https://tuba.geopjr.dev/
GNU General Public License v3.0
570 stars 60 forks source link

[Bug]: crash after rapidly closing media viewer #1102

Closed camelCaseNick closed 1 month ago

camelCaseNick commented 1 month ago

Describe the bug

The crash happens when tuba_views_media_viewer_item_add_spinner_to_overlay gets run after its timeout, when that happens after the media viewer item was finalised already. It appears to only happen in the release version, but there reproducibly.

Steps To Reproduce

  1. open Tuba
  2. open the media viewer
  3. close it fast (from the location where it crashes in, I assume it has to be less than 1 s)
  4. experience crash

Logs and/or Screenshots

Core was generated by `dev.geopjr.Tuba'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055b3d9781efd in tuba_views_media_viewer_item_add_spinner_to_overlay (self=0x55b3fe6ced50) at ../src/Views/MediaViewer.vala:220
220             if (is_done) return;
[Current thread is 1 (Thread 0x7f1600f3b280 (LWP 2))]
(gdb) bt full
#0  0x000055b3d9781efd in tuba_views_media_viewer_item_add_spinner_to_overlay (self=0x55b3fe6ced50) at ../src/Views/MediaViewer.vala:220
        _tmp0_ = <optimized out>
        _tmp1_ = <optimized out>
        _tmp0_ = <optimized out>
        _tmp1_ = <optimized out>
        __func__ = "tuba_views_media_viewer_item_add_spinner_to_overlay"
        _g_boolean_var_96 = <optimized out>
#1  _tuba_views_media_viewer_item_add_spinner_to_overlay_gsource_once_func (self=0x55b3fe6ced50, self@entry=<error reading variable: value has been optimized out>)
    at ../src/Views/MediaViewer.vala:214
#2  0x00007f1606b8658f in g_timeout_dispatch (source=0x55b3fe746680, callback=<optimized out>, user_data=<optimized out>) at ../glib/gmain.c:4984
        once_callback = <optimized out>
        timeout_source = 0x55b3fe746680
        again = <optimized out>

[…]

When running with debug messages, you can see

(dev.geopjr.Tuba:2): Tuba-DEBUG: 03:48:41.897: MediaViewer.vala:246: Destroying MediaViewer.Item

in the logs, so the media viewer gets destroyed before the crash.

Therefore, it looks like tuba_views_media_viewer_item_add_spinner_to_overlay is not properly detached at destruction. However, I cannot reproduce it when building the devel build.

Instance Backend

Mastodon

Operating System

Debian testing

Package

Flatpak

Troubleshooting information

No response

Additional Context

No response

GeopJr commented 1 month ago

Thanks for raising this issue!

Has been fixed on #1099 (specifically 2f71486118a6fc455d41c19b65cedb2302654f7c), unfortunately noticed too late when implementing the audio visualizer :(

(you would think Vala would detach timeouts automatically... :shrug:)

camelCaseNick commented 1 month ago

Ooops. I looked at the commit history, but nothing looked like it was related to this issue. (due to the squash merging style) I assumed the GLib.Source.remove was there all along and weirdly optimised out.