mate-desktop / mozo

Menu editor for MATE using the freedesktop.org menu specification
http://www.mate-desktop.org
GNU Lesser General Public License v2.1
28 stars 12 forks source link

Constant segmentation faults #90

Open adefaria opened 1 month ago

adefaria commented 1 month ago

Expected behaviour

Well, not segmentation faults!

Actual behaviour

Segmentation faults

Earth:mozo

(mozo:1224506): dbind-WARNING **: 11:49:21.564: Couldn't connect to accessibility bus: Failed to connect to socket /root/.cache/at-spi/buslocalhost_11.0: Permission denied

(mate-desktop-item-edit:1224552): dbind-WARNING **: 11:49:54.471: Couldn't connect to accessibility bus: Failed to connect to socket /root/.cache/at-spi/buslocalhost_11.0: Permission denied
Segmentation fault (core dumped)
Earth:

Steps to reproduce the behaviour

Seems to happen whenever I change properties. Usually, the change happens but I have to restart mozo for the next modification

MATE general version

Mate Desktop Environment 1.26.2

Package version

Earth:apt list mozo
Listing... Done
mozo/noble,noble,now 1.26.2-1 all [installed]
Earth:

Linux Distribution

Ubuntu 24.04 (but it happened on 22.04 too)

Link to bugreport of your Distribution (requirement)

Not sure how to do that

lukefromdc commented 1 month ago

wonder if this is related to https://github.com/mate-desktop/mozo/issues/89 in any way. That one is caused by the fact that mozo and and mate-control-center's preferred applications capplet are both writing to the same filenames in ~/.local/share/applications/ without preserving the previous content. I could see a problem with these files getting corrupted possibly causing some builds to segfault

mesov commented 1 month ago

wonder if this is related to #89 in any way.

Could this be happening because mozo runs mate-desktop-item-edit, which in turn tries to write in /usr/share/applications/ but does not have permission to do so? So it creates a new .desktop file in ~/.local/share/applications/ instead. In some systems the failed write attempt may fail silently, while it may segfault on others.

I cannot reproduce #89 if I run sudo mozo.

adefaria commented 1 month ago

Still a problem for me, even with sudo:

Earth:sudo mozo
Segmentation fault
Earth:
mesov commented 1 month ago

What happens if you run mate-desktop-item-edit /usr/share/applications/mozo.desktop ?

adefaria commented 1 month ago

I get:

Earth:mate-desktop-item-edit /usr/share/applications/mozo.desktop

(mate-desktop-item-edit:28290): dbind-WARNING **: 08:35:45.027: Couldn't connect to accessibility bus: Failed to connect to socket /root/.cache/at-spi/bus_0.0: Permission denied

Screenshot at 2024-10-24 08-37-15

And a window of

mesov commented 1 month ago

I am getting the same. Then if I try to change the Name into Main Menu Test I get a "Permission denied" error message when I try to Close the Launcher Properties window.

adefaria commented 1 month ago

Same here. What I'm not getting is the segfault. I just get them from the mozo application. Perhaps mozo is failing to handle that permission denied exception properly?

cwendling commented 1 month ago

What would help to pinpoint the issue would be installing mozo debugging symbols (not sure how that's done in Ubuntu nowadays, maybe just sudo apt install mozo-dbgsym?), and ideally the same for support libraries, and the run under a debugger:

$ gdb -ex run --args mozo

and when it crashes, get a backtrace with bt full at the GDB prompt. Then, paste the backtrace here so somebody can have an idea what's actually happening.

mesov commented 1 month ago

help to pinpoint the issue

Indeed. I believe #89 has been pinpointed to:

If a desktop entry is present both in a system location and in ~/.local/share/applications, it fails to show up in the result from g_app_info_get_all_for_type().

which can be bypassed either by running mozo with sudo permissions or by running update-desktop-database ~/.local/share/applications/. By contrast, the segfault here persists even with write permissions.

adefaria commented 1 month ago

update-desktop-database doesn't work for my user, it does for root. However, running sudo mozo does work but it edit's root's menu not my user's menu

Earth:update-desktop-database 
The databases in [/usr/share/mate/applications, /usr/share/mate/applications, /usr/share/gnome/applications, /home/andrew/.local/share/flatpak/exports/share/applications, /var/lib/flatpak/exports/share/applications, /usr/local/share/applications, /usr/share/applications, /var/lib/snapd/desktop/applications] could not be updated.
Earth:
mesov commented 1 month ago

Sorry, I meant that the segfault reported here is very possibly a different issue to the one reported in #89.

So you should probably follow cwendling's guidance https://github.com/mate-desktop/mozo/issues/90#issuecomment-2435713555 above to help pinpoint it.

adefaria commented 1 month ago

Well /bin/mozo is a Python script so gdb doesn't work and I'm not that versed in Python to debug further.

cwendling commented 1 month ago

Ah, didn't realize that mozo was written in Python :) Well, there are two options: PDB, or still run GDB if it's a crash it might still be useful. For GDB, just explicitly run python as well: gdb -ex run --args python3 "$(command -v mozo)". For PDB I'm less fluent, but potentially a mere python3 -m pdb -c continue "$(command -v mozo)" might be enough to help.

adefaria commented 1 month ago

As I said, neither my gdb or pdb skills are up for the task... If you can reproduce this then perhaps you can debug it. It's annoying to work with but I can work with it as it is. It just takes several restarts to get things done...

lukefromdc commented 1 month ago

I haven't had any problem with segfaults in Mozo. This might depend on things like what version of python you have, or even be a problem in some versions of python themselves.

mesov commented 1 month ago

For the record, you do not need to run update-desktop-database without options since your system is already taking care of that. What you need to run in order to update the mimeinfo cache file in your user directory is the whole line:

update-desktop-database ~/.local/share/applications/

which does not require root permissions.

mesov commented 1 month ago

a mere python3 -m pdb -c continue "$(command -v mozo)" might be enough to help.

I can confirm that running that line was enough to get mozo to run in debug mode. Expectedly, I got no error.

xatziaris commented 3 weeks ago

By running the following and reproducing the error:

gdb -ex run --args python3 "$(command -v mozo)"

... I get:

GNU gdb (Ubuntu 12.1-0ubuntu1~22.04.2) 12.1 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: https://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/.

For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from python3... (No debugging symbols found in python3) Starting program: /usr/bin/python3 /usr/bin/mozo [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff5000640 (LWP 97947)] [New Thread 0x7fffefe00640 (LWP 97948)] [New Thread 0x7fffef400640 (LWP 97949)] [New Thread 0x7fffeea00640 (LWP 97950)] [New Thread 0x7fffed000640 (LWP 97951)] [Thread 0x7fffed000640 (LWP 97951) exited] [New Thread 0x7fffed000640 (LWP 97952)] [New Thread 0x7fffe6000640 (LWP 97953)] [Thread 0x7fffed000640 (LWP 97952) exited] [New Thread 0x7fffed000640 (LWP 97954)] [New Thread 0x7fffe5600640 (LWP 97955)] [Thread 0x7fffe6000640 (LWP 97953) exited] [Thread 0x7fffed000640 (LWP 97954) exited] [Thread 0x7fffe5600640 (LWP 97955) exited] [New Thread 0x7fffe5600640 (LWP 97956)] [New Thread 0x7fffed000640 (LWP 97957)] [Thread 0x7fffe5600640 (LWP 97956) exited] [New Thread 0x7fffe5600640 (LWP 97958)] [New Thread 0x7fffe6000640 (LWP 97959)] [Thread 0x7fffed000640 (LWP 97957) exited] [Thread 0x7fffe5600640 (LWP 97958) exited] [Thread 0x7fffe6000640 (LWP 97959) exited] [New Thread 0x7fffe6000640 (LWP 97960)] [New Thread 0x7fffe5600640 (LWP 97961)] [Thread 0x7fffe6000640 (LWP 97960) exited] [New Thread 0x7fffe6000640 (LWP 97962)] [New Thread 0x7fffed000640 (LWP 97963)] [Thread 0x7fffe5600640 (LWP 97961) exited] [Thread 0x7fffe6000640 (LWP 97962) exited] [Thread 0x7fffed000640 (LWP 97963) exited] [New Thread 0x7fffed000640 (LWP 97964)] [Thread 0x7fffeea00640 (LWP 97950) exited] [New Thread 0x7fffeea00640 (LWP 97965)] [New Thread 0x7fffe6000640 (LWP 97966)] [Thread 0x7fffeea00640 (LWP 97965) exited] [New Thread 0x7fffeea00640 (LWP 97967)] [New Thread 0x7fffe5600640 (LWP 97968)] [Thread 0x7fffe6000640 (LWP 97966) exited] [Thread 0x7fffeea00640 (LWP 97967) exited] [Thread 0x7fffe5600640 (LWP 97968) exited] [Detaching after vfork from child process 97970] [New Thread 0x7fffe5600640 (LWP 97990)] [New Thread 0x7fffeea00640 (LWP 97991)] [Thread 0x7fffe5600640 (LWP 97990) exited] [New Thread 0x7fffe5600640 (LWP 97992)] [Thread 0x7fffeea00640 (LWP 97991) exited] [New Thread 0x7fffeea00640 (LWP 97993)] [Thread 0x7fffe5600640 (LWP 97992) exited] [New Thread 0x7fffe5600640 (LWP 97994)] [Thread 0x7fffeea00640 (LWP 97993) exited] [New Thread 0x7fffeea00640 (LWP 97995)] [Thread 0x7fffe5600640 (LWP 97994) exited] [New Thread 0x7fffe5600640 (LWP 97996)] [New Thread 0x7fffeea00640 (LWP 97997)] [Thread 0x7fffeea00640 (LWP 97995) exited] [Thread 0x7fffe5600640 (LWP 97996) exited] [Thread 0x7fffeea00640 (LWP 97997) exited] [New Thread 0x7fffeea00640 (LWP 97998)] [New Thread 0x7fffe5600640 (LWP 97999)] [New Thread 0x7fffe6000640 (LWP 98000)] [New Thread 0x7fffe4c00640 (LWP 98001)] [New Thread 0x7fffbbe00640 (LWP 98002)] [New Thread 0x7fffbb400640 (LWP 98003)] [Thread 0x7fffbbe00640 (LWP 98002) exited] [New Thread 0x7fffbbe00640 (LWP 98004)] [New Thread 0x7fffbaa00640 (LWP 98005)] [Thread 0x7fffbb400640 (LWP 98003) exited] [Thread 0x7fffbbe00640 (LWP 98004) exited] [Thread 0x7fffbaa00640 (LWP 98005) exited] [New Thread 0x7fffbaa00640 (LWP 98006)] [New Thread 0x7fffbbe00640 (LWP 98007)] [Thread 0x7fffbaa00640 (LWP 98006) exited] [New Thread 0x7fffbaa00640 (LWP 98008)] [New Thread 0x7fffbb400640 (LWP 98009)] [Thread 0x7fffbbe00640 (LWP 98007) exited] [Thread 0x7fffbaa00640 (LWP 98008) exited] [Thread 0x7fffbb400640 (LWP 98009) exited] [Detaching after vfork from child process 98013]

Thread 1 "python3" received signal SIGSEGV, Segmentation fault. 0x00007ffff47f0747 in matemenu_tree_item_ref () from /lib/x86_64-linux-gnu/libmate-menu.so.2 (gdb)

/----------------------------/

Edit: I am using Python 3.10.12

lukefromdc commented 3 weeks ago

That sounds like we are unrefing something in the menu and then trying to increment the reference count on it again. Since we are using python bindings for GTK, that suggests we are somehow forcing python to do something that normally would only happen in a C or C++ program.

I don't really know much about python's inner workings, but fixing the actual problem could make the details about why this is able to segfault at all irrelevent.