libretiny-eu / ltchiptool

Universal, easy-to-use GUI flashing/dumping tool for BK7231, RTL8710B and RTL8720C.
MIT License
67 stars 4 forks source link

Segmentation fault in Fedora 39 #17

Open BoukeHaarsma23 opened 5 months ago

BoukeHaarsma23 commented 5 months ago

Hi, thanks for your hard work. It is appreciated.

I am wanting to flash a module using my linux laptop. But I am hitting an assertion here.

[bouke@Slimbook ~]$ ltchiptool -vvv gui
22:31:53: Debug: Adding duplicate image handler for 'Windows bitmap file'
22:31:53: Debug: Adding duplicate animation handler for '1' type
22:31:53: Debug: Adding duplicate animation handler for '2' type
D: Found Local data snapshot (v1.4.1) - /home/bouke/.local/lib/python3.12/site-packages/ltchiptool
D: Using v1.4.1 (/home/bouke/.local/lib/python3.12/site-packages/ltchiptool) as default
D: Using selector: EpollSelector

(ltchiptool:58704): Gtk-CRITICAL **: 22:31:53.843: gtk_box_gadget_distribute: assertion 'size >= 0' failed in GtkScrollbar
D: Started DeviceWatcher
Segmentation fault (core dumped)

Using Fedora 39 and using all pypi packages. The GUI first starts normally, but gets this segmentation fault when switching tabs. Using v4.10.1

Would appreciate if you could take a look. (As a suggestion maybe consider a flatpak in the future?)

alufers commented 5 months ago

I am also getting those crashes, the gtk_box_gadget_distribute: assertion 'size >= 0' failed line seems to be bogus, the segfaults happen in different places in the code.

I think the cause of these crashes is the fact that ltchiptool does GUI operations from multiple threads, which GTK does not like (this might also be the cause of macOS crashes).

I quickly added this piece code to a few places:

import threading
print("PluginsPanel.__init__, get_native_id=", threading.get_native_id())

And from the logs I can see that OnWorkStopped is called from a different thread (and it also manipulates the GUI):

PluginsPanel.__init__, get_native_id= 307888
StartWork get_native_id= 307888
PluginsPanel.OnWorkStopped, get_native_id= 307943
kuba2k2 commented 5 months ago

Good point. That might have been not an issue on Windows, and since I'm developing on Windows I never noticed such things - all this is actually my first go at wxPython and GUI apps.

It should be possible to convert these worker thread callbacks so that they execute on main thread. I think something similar has been implemented in another class already; I'm not sure where exactly.

Something similar has been implemented here: https://github.com/tuya-cloudcutter/cloudcutter-universal/blob/master/cloudcutter/modules/base/event.py but that relies on AsyncIO for the entire project.

kuba2k2 commented 4 months ago

Hi, this got closed automatically. If you can, let me know if the issue is solved (at least partially). Clicking on the Plugins tab is still a known issue on Linux.