lxqt / lxqt-session

The LXQt session manager
https://lxqt.github.io
GNU Lesser General Public License v2.1
57 stars 52 forks source link

crash on startup if XDG_DESKTOP_DIR not set in user-dirs.dirs #439

Closed wamserma closed 2 years ago

wamserma commented 2 years ago

If ~/.config/user-dirs.dirs is not empty but missing an entry for XDG_DESKTOP_DIR, a crash is reported upon logging in to a fresh LXQt session.

This was encountered while updating from NixOS 21.11 to 22.05 (LXQt 0.17 to 1.1.0). Leaving ~/.config/user-dirs.dirs empty, removing it or adding the entry with a text editor solved the issue. Only having e.g. an entry for XDG_PICTURES_DIR triggered the crash.

This was confirmed on Ubuntu 22.04 (yes LTS, but very fresh) with LXQt on Mutter. Simply commenting out the line with XDG_DESKTOP_DIR triggered the crash at next login (crash was reported for mutter).

Expected Behavior

LXQt should fall back to XDG_DESKTOP_DIR=$HOME/Desktop

Current Behavior

See description above.

Possible Solution

See above.

Steps to Reproduce (for bugs)
  1. Use a system with recent LXQt
  2. Ensure ~/.config/user-dirs.dirsis not empty, but has no entry for XDG_DESKTOP_DIR
  3. If necessary, log out.
  4. Log in to a new LXQt session, observe crash.
Context

This might not be in lxqt-session (though https://github.com/lxqt/lxqt-session/blob/9d63aba3cdb88dafb837fe3e94ada3047de7ec0c/startlxqt.in#L39 looks suspicious, but also this https://github.com/lxqt/pcmanfm-qt/blob/4659da4f7428abb43326b794a9983006dbead3a3/pcmanfm/xdgdir.cpp#L35)

System Information

The core dump I got on NixOS:

Process 2016 (.pcmanfm-qt-wra) of user 1000 dumped core.

                                                 Module linux-vdso.so.1 with build-id 95945c6f4f0a2d417f23f38a4d5cb85d7df2f0ad
                                                 Module librt.so.1 with build-id 81dcc5b293a378ea5ee6ff8ba1e67b8f55381439
                                                 Module libnvidia-glcore.so.470.129.06 with build-id 3c47a74290af64e361d1c6d3db2d9ff58c5630ac
                                                 Module libnvidia-tls.so.470.129.06 with build-id 3ca4766f92acd8cdd390b155c8d03fc032ad9a87
                                                 Module libnvidia-glsi.so.470.129.06 with build-id c6be8cb7d79dbb9e605a54f99789ee6c745e9c57
                                                 Module libGLX_nvidia.so.0 with build-id 770adb36d1578a94a7a57f119f745b74018daacd
                                                 Module libxcb-glx.so.0 without build-id.
                                                 Module libqxcb-glx-integration.so without build-id.
                                                 Module libjpeg.so.62 without build-id.
                                                 Module libqjpeg.so without build-id.
                                                 Module libgioremote-volume-monitor.so without build-id.
                                                 Module libgvfscommon.so without build-id.
                                                 Module libgvfsdbus.so without build-id.
                                                 Module libcomposeplatforminputcontextplugin.so without build-id.
                                                 Module libQt5Svg.so.5 without build-id.
                                                 Module libQt5XdgIconLoader.so.3 without build-id.
                                                 Module libdbusmenu-qt5.so.2 without build-id.
                                                 Module libqtlxqt.so without build-id.
                                                 Module libXfixes.so.3 without build-id.
                                                 Module libXrender.so.1 without build-id.
                                                 Module libXcursor.so.1 without build-id.
                                                 Module libuuid.so.1 with build-id 7569ec2686055355f8a05497dfdb27fef759aa3e
                                                 Module libxcb-util.so.1 without build-id.
                                                 Module libexpat.so.1 without build-id.
                                                 Module libxkbcommon.so.0 without build-id.
                                                 Module libxkbcommon-x11.so.0 without build-id.
                                                 Module libICE.so.6 without build-id.
                                                 Module libSM.so.6 without build-id.
                                                 Module libxcb-xinput.so.0 without build-id.
                                                 Module libxcb-xkb.so.1 without build-id.
                                                 Module libxcb-xinerama.so.0 without build-id.
                                                 Module libxcb-xfixes.so.0 without build-id.
                                                 Module libxcb-sync.so.1 without build-id.
                                                 Module libxcb-shape.so.0 without build-id.
                                                 Module libxcb-render.so.0 without build-id.
                                                 Module libxcb-render-util.so.0 without build-id.
                                                 Module libxcb-randr.so.0 without build-id.
                                                 Module libxcb-keysyms.so.1 without build-id.
                                                 Module libxcb-shm.so.0 without build-id.
                                                 Module libxcb-image.so.0 without build-id.
                                                 Module libxcb-icccm.so.4 without build-id.
                                                 Module libX11-xcb.so.1 without build-id.
                                                 Module libfontconfig.so.1 without build-id.
                                                 Module libQt5XcbQpa.so.5 without build-id.
                                                 Module libqxcb.so without build-id.
                                                 Module libgpg-error.so.0 without build-id.
                                                 Module libbz2.so.1 without build-id.
                                                 Module libgcrypt.so.20 without build-id.
                                                 Module libcap.so.2 without build-id.
                                                 Module liblz4.so.1 without build-id.
                                                 Module liblzma.so.5 without build-id.
                                                 Module libdl.so.2 with build-id a4bfa88c56b19d9a13f5191cfe661e9b9f32140a
                                                 Module libblkid.so.1 with build-id cf73678494b22fed110740fbedf2a7f0f6c80587
                                                 Module libgraphite2.so.3 without build-id.
                                                 Module libfreetype.so.6 without build-id.
                                                 Module libGLdispatch.so.0 without build-id.
                                                 Module libXext.so.6 without build-id.
                                                 Module libX11.so.6 without build-id.
                                                 Module libGLX.so.0 without build-id.
                                                 Module libsystemd.so.0 without build-id.
                                                 Module libXdmcp.so.6 without build-id.
                                                 Module libXau.so.6 without build-id.
                                                 Module libffi.so.8 without build-id.
                                                 Module libselinux.so.1 without build-id.
                                                 Module libmount.so.1 with build-id c512478563c1864d6b835ae7023d81dc2f9c6912
                                                 Module libgmodule-2.0.so.0 with build-id a78312de0825709eb9f8e260c81f0203f45d7cb5
                                                 Module libpcre.so.1 without build-id.
                                                 Module ld-linux-x86-64.so.2 with build-id 2d4e3d041d24aa7a72377e8cc41e9336abd77ffb
                                                 Module libzstd.so.1 without build-id.
                                                 Module libpcre2-16.so.0 without build-id.
                                                 Module libicudata.so.71 without build-id.
                                                 Module libicuuc.so.71 without build-id.
                                                 Module libicui18n.so.71 without build-id.
                                                 Module libharfbuzz.so.0 without build-id.
                                                 Module libz.so.1 without build-id.
                                                 Module libpng16.so.16 without build-id.
                                                 Module libGL.so.1 without build-id.
                                                 Module libdbus-1.so.3 without build-id.
                                                 Module libpthread.so.0 with build-id bff749b993405063a72406b65328ce34b1d20b2b
                                                 Module libc.so.6 with build-id c512f38583c48b03cc0011d4583d15cea2e94d03
                                                 Module libgcc_s.so.1 without build-id.
                                                 Module libm.so.6 with build-id ab70ae196025b3056f0fc0ed85a43390cda0ea4a
                                                 Module libstdc++.so.6 without build-id.
                                                 Module libexif.so.12 without build-id.
                                                 Module libxcb.so.1 without build-id.
                                                 Module libmenu-cache.so.3 without build-id.
                                                 Module libgthread-2.0.so.0 with build-id 8ebac81baef149f7c3c15af45a2b9e96bb5c19aa
                                                 Module libgobject-2.0.so.0 with build-id aad6dfac42cb975a483059295763c1da5af4f29c
                                                 Module libgio-2.0.so.0 with build-id 6544023370a455ba189fdf104ab3622407f949c3
                                                 Module libglib-2.0.so.0 with build-id 38c99a0e74889fd6e0b4677edb87634f8d198b36
                                                 Module libQt5Core.so.5 without build-id.
                                                 Module libQt5Gui.so.5 without build-id.
                                                 Module libQt5Widgets.so.5 without build-id.
                                                 Module libQt5X11Extras.so.5 without build-id.
                                                 Module libfm-qt.so.11 without build-id.
                                                 Module libQt5DBus.so.5 without build-id.
                                                 Module .pcmanfm-qt-wrapped without build-id.
                                                 Stack trace of thread 2016:
                                                 #0  0x00007fc2e4f12ad4 __strcmp_sse2 (libc.so.6 + 0xa7ad4)
                                                 #1  0x00007fc2e6ae84bb _ZN2Fm6Folder17onDirListFinishedEv (libfm-qt.so.11 + 0x8e4bb)
                                                 #2  0x00007fc2e5a6f9be _ZN7QObject5eventEP6QEvent (libQt5Core.so.5 + 0x2f69be)
                                                 #3  0x00007fc2e65086cf _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent (libQt5Widgets.so.5 + 0x1716cf)
                                                 #4  0x00007fc2e5a42f5a _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent (libQt5Core.so.5 + 0x2c9f5a)
                                                 #5  0x00007fc2e5a46067 _ZN23QCoreApplicationPrivate16sendPostedEventsEP7QObjectiP11QThreadData (libQt5Core.so.5 + 0x2cd067)
                                                 #6  0x00007fc2e5a9b363 n/a (libQt5Core.so.5 + 0x322363)
                                                 #7  0x00007fc2e5695dfb g_main_context_dispatch (libglib-2.0.so.0 + 0x56dfb)
                                                 #8  0x00007fc2e56960a8 g_main_context_iterate.constprop.0 (libglib-2.0.so.0 + 0x570a8)
                                                 #9  0x00007fc2e569615f g_main_context_iteration (libglib-2.0.so.0 + 0x5715f)
                                                 #10 0x00007fc2e5a9a9c4 _ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE (libQt5Core.so.5 + 0x3219c4)
                                                 #11 0x00007fc2e5a418db _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE (libQt5Core.so.5 + 0x2c88db)
                                                 #12 0x00007fc2e5a49f20 _ZN16QCoreApplication4execEv (libQt5Core.so.5 + 0x2d0f20)
                                                 #13 0x000000000042a074 main (.pcmanfm-qt-wrapped + 0x2a074)
                                                 #14 0x00007fc2e4e94237 __libc_start_call_main (libc.so.6 + 0x29237)
                                                 #15 0x00007fc2e4e942f5 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x292f5)
                                                 #16 0x000000000042a101 _start (.pcmanfm-qt-wrapped + 0x2a101)
tsujan commented 2 years ago

Thank you very much for reporting!

I'll investigate the part related to pcmanfm-qt soon.

palinek commented 2 years ago

Based on the dump, the problem would probably be comparing null here -> https://github.com/lxqt/libfm-qt/blob/master/src/core/folder.cpp#L535

EDIT: As the URI scheme can be null -> https://libsoup.org/gio/GFile.html#g-file-get-uri-scheme

@tsujan Shouldn't we rather use there the hasUriScheme:

diff --git a/src/core/folder.cpp b/src/core/folder.cpp
index 5bb4013..710a913 100644
--- a/src/core/folder.cpp
+++ b/src/core/folder.cpp
@@ -532,7 +532,7 @@ void Folder::onDirListFinished() {
     const auto& infos = job->files();

     // with "search://", there is no update for infos and all of them should be added
-    if(strcmp(dirPath_.uriScheme().get(), "search") == 0) {
+    if(dirPath_.hasUriScheme("search")) {
         files_to_add = infos;
         for(auto& file: files_to_add) {
             files_[file->path().baseName().get()] = file;
tsujan commented 2 years ago

Yes, either Fm::FilePath::hasUriScheme() or g_strcmp0() needs to be used there. That should be fixed. Thanks!

But, IMO, we should also prevent an empty string for desktop.

wamserma commented 2 years ago

But, IMO, we should also prevent an empty string for desktop.

+1

tsujan commented 2 years ago

https://github.com/lxqt/libfm-qt/pull/808 will fix the crash and close this report after it's merged. It's the same as @palinek's fix above.

For users' convenience, I'll make another PR for preventing an empty Desktop path in pcmanfm-qt.

As for lxqt-session, another report could be made for it if it really needs a change in this regard. Since the crash will be fixed by the above-mentioned PR, I don't think more change is needed.

wamserma commented 2 years ago

I can confirm the crash is fixed by https://github.com/lxqt/libfm-qt/pull/808.

Preventing an empty desktop path is still a good idea.

Regarding lxqt-session: I was torn whether I should open the issue here or in libfm-qt. I simply chose this repo, because it manifested upon login. No further changes needed for lxqt-session.

tsujan commented 2 years ago

@wamserma Thanks for testing!

Preventing an empty desktop path is still a good idea.

I'll make a pcmanfm-qt PR for that soon.

tsujan commented 2 years ago

This is the PR for pcmanfm-qt: https://github.com/lxqt/pcmanfm-qt/pull/1601.

An empty desktop path will be accepted only if it's set explicitly in ~/.config/user-dirs.dirs, like XDG_DESKTOP_DIR=""; otherwise — if the file doesn't exist or doesn't contain a desktop path — $HOME/Desktop will be used.