lxqt / lxqt-session

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

Heads up: procps-ng #427

Closed jubalh closed 1 year ago

jubalh commented 2 years ago

Sorry, I wasn't sure where it's best to discuss this. So I chose this place here.

If I'm not mistaken we are looking for libprocps at https://github.com/lxqt/lxqt-session/blob/master/CMakeLists.txt#L36

It seems to me that procps has been replaces by procps-ng. The packageconfig file has been changed from libprocps to libproc-2.

Our tests probably will only look for the old version. Some distros will use the -ng variant as a drop in replacement I think.

Do we have any plans to update to the latest version of procps-ng ?

@tsujan @stefonarch what is the state in Arch about this?

tsujan commented 2 years ago

I took a look at my pacman log: the first upgrade of procps-ng happened here in 2017-12-10. My log starts in 2017-05-20; so, procps-ng should have been used before that time.

EDIT: The version of procps-ng is 3.3.17-1 now, upgraded in 2021-02-24 here.

tsujan commented 2 years ago

The main files of procps-ng:

pacman -Ql procps-ng
procps-ng /usr/
procps-ng /usr/bin/
procps-ng /usr/bin/free
procps-ng /usr/bin/pgrep
procps-ng /usr/bin/pidof
procps-ng /usr/bin/pkill
procps-ng /usr/bin/pmap
procps-ng /usr/bin/ps
procps-ng /usr/bin/pwait
procps-ng /usr/bin/pwdx
procps-ng /usr/bin/slabtop
procps-ng /usr/bin/sysctl
procps-ng /usr/bin/tload
procps-ng /usr/bin/top
procps-ng /usr/bin/uptime
procps-ng /usr/bin/vmstat
procps-ng /usr/bin/w
procps-ng /usr/bin/watch
procps-ng /usr/include/
procps-ng /usr/include/proc/
procps-ng /usr/include/proc/alloc.h
procps-ng /usr/include/proc/devname.h
procps-ng /usr/include/proc/escape.h                                                                                   
procps-ng /usr/include/proc/numa.h                                                                                     
procps-ng /usr/include/proc/procps.h                                                                                   
procps-ng /usr/include/proc/pwcache.h                                                                                  
procps-ng /usr/include/proc/readproc.h                                                                                 
procps-ng /usr/include/proc/sig.h                                                                                      
procps-ng /usr/include/proc/slab.h                                                                                     
procps-ng /usr/include/proc/sysinfo.h                                                                                  
procps-ng /usr/include/proc/version.h                                                                                  
procps-ng /usr/include/proc/wchan.h                                                                                    
procps-ng /usr/include/proc/whattime.h                                                                                 
procps-ng /usr/lib/                                                                                                    
procps-ng /usr/lib/libprocps.so                                                                                        
procps-ng /usr/lib/libprocps.so.8                                                                                      
procps-ng /usr/lib/libprocps.so.8.0.3                                                                                  
procps-ng /usr/lib/pkgconfig/                                                                                          
procps-ng /usr/lib/pkgconfig/libprocps.pc 
....
DimStar77 commented 2 years ago

The important change is procps-ng 4.0, released end of March 2022

DimStar77 commented 2 years ago

https://gitlab.com/procps-ng/procps/-/commit/9aa09d8862c00a8dc85910d0365332c8c99b59ce is the relevant upstream change

tsujan commented 2 years ago

The important change is procps-ng 4.0, released end of March 2022

Then, we'll need to handle it in a point release after LXQt 1.1.0.

jubalh commented 2 years ago

Indeed Arch is still on 3.3.17: https://github.com/archlinux/svntogit-packages/blob/packages/procps-ng/trunk/PKGBUILD While procps-ng 4.0.0 was released 2 weeks ago: https://gitlab.com/procps-ng/procps/-/releases#v4.0.0

So probably will hit Arch soonish.

Gentoo also still is on 3.3.17: https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-process/procps Debian unstable has 4.0.0 as well. But AFAIK they don't have any LXQt maintainer anymore.

berolinux commented 2 years ago

It's now hitting OpenMandriva.

Unfortunately the fix is a bit more complicated than just changing the library name -- the API has changed as well.

berolinux commented 2 years ago

Completely untested patch based on just reading the diff between procps-ng 3.3.17 and 4.0.0.

Passes Windows-style QA ("It compiles, therefore it works").

Will send a proper MR once I (or someone else) got around to testing it.

lxqt-session-1.1.1-procps-ng-4.0.patch.txt

palinek commented 2 years ago

@berolinux Thanks for taking care of this.

Visone-Selektah commented 1 year ago

Hi! The release 1.2.0 still have the same issue. I'm gonna try that patch.

tsujan commented 1 year ago

The release 1.2.0 still have the same issue.

To this date, Arch's procps-ng is still 3.3.17-1. Gentoo too.

Visone-Selektah commented 1 year ago

Hi! Thanks for answering!! I'm packaging it for venom-linux and we port procps-ng 4.0.1 I tried that patch too but still fail to build

tsujan commented 1 year ago

It'll be investigated by devs when they get procps-ng ≥ 4. I don't know if a backward-compatible patch will be possible.

Visone-Selektah commented 1 year ago

Hi! OK It'll have to wait..... I'll keep an eye to this thread anyway.... Thanks!!!

ncopa commented 1 year ago

Hitting this in Alpine Linux now, while upgrading procps to 4

ncopa commented 1 year ago

I wonder if it would make more sense to get rid of procps dependency and get the ppids by doing some thing equivalent to

awk '$1=="PPid:" {print $2}' /proc/*/status
ncopa commented 1 year ago

Maybe something like this?

Only compile-time tested, but you get the idea.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a3c5e0d..db516ab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,9 +34,6 @@ find_package(qtxdg-tools ${QTXDG_MINIMUM_VERSION} REQUIRED)
 find_package(X11 REQUIRED)
 message(STATUS "Building with Qt${Qt5Core_VERSION}")
 find_package(PkgConfig REQUIRED)
-if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
-    pkg_search_module(PROCPS REQUIRED libprocps)
-endif()

 # Please don't move, must be after lxqt
 find_package(XdgUserDirs REQUIRED)
diff --git a/lxqt-session/src/procreaper.cpp b/lxqt-session/src/procreaper.cpp
index 2acd030..0cd8255 100644
--- a/lxqt-session/src/procreaper.cpp
+++ b/lxqt-session/src/procreaper.cpp
@@ -28,8 +28,11 @@
 #include "procreaper.h"
 #include "log.h"
 #if defined(Q_OS_LINUX)
+#include <QDir>
+#include <QString>
+#include <QStringList>
+#include <QDirIterator>
 #include <sys/prctl.h>
-#include <proc/readproc.h>
 #elif defined(Q_OS_FREEBSD)
 #include <sys/procctl.h>
 #include <libutil.h>
@@ -109,16 +112,28 @@ void ProcReaper::stop(const std::set<int64_t> & excludedPids)
     const pid_t my_pid = ::getpid();
     std::vector<pid_t> children;
 #if defined(Q_OS_LINUX)
-    PROCTAB * proc_dir = ::openproc(PROC_FILLSTAT);
-    while (proc_t * proc = ::readproc(proc_dir, nullptr))
+    QDirIterator it(QStringLiteral("/proc"), { QStringLiteral("[0-9]*") }, QDir::NoFilter);
+    while (it.hasNext())
     {
-        if (proc->ppid == my_pid)
+        QDir dir(it.next());
+        QFile f(dir.filePath(QStringLiteral("status")));
+        if (!f.open(QIODevice::ReadOnly))
+            continue;
+        QTextStream in(&f);
+        while (!in.atEnd())
         {
-            children.push_back(proc->tgid);
+            QString line = in.readLine();
+            if (line.startsWith(QStringLiteral("PPid:\t")))
+            {
+                pid_t ppid = line.remove(0, 6).toInt();
+                if (ppid == my_pid)
+                {
+                    children.push_back(dir.dirName().toInt());
+                }
+                break;
+            }
         }
-        ::freeproc(proc);
     }
-    ::closeproc(proc_dir);
 #elif defined(Q_OS_FREEBSD)
     int cnt = 0;
     if (kinfo_proc *proc_info = kinfo_getallproc(&cnt))
czchen commented 1 year ago

@tsujan Could you help to provide test scenarios for using libproc2 in lxqt-session so that we can confirm if this works for Debian or not?

We are working on migrating lxqt-session to use libproc2 in Debian. Currently we use patch from @berolinux and has uploaded patched version to experimental. We would like to do some test before merging it into unstable distribution.

tsujan commented 1 year ago

I'm afraid it's outside my area of expertise. Perhaps @palinek could comment on the patch and possible tests.

benbullard79 commented 1 year ago

In OpenMandriva we have this patch: https://github.com/OpenMandrivaAssociation/lxqt-session/blob/master/lxqt-session-1.1.1-procps-ng-4.0.patch

And procps-ng-4.0.0. We still have https://github.com/OpenMandrivaAssociation/distribution/issues/2816.

I am not a developer but I think maybe the procps-ng issue is cause of OM bug 2816.

palinek commented 1 year ago

I tried to address the procps-ng situation in #456 (using the patch from @berolinux for the libproc2). Please, we would need as much tests as possible.

stefonarch commented 1 year ago

Please, we would need as much tests as possible.

I've running it in debian testing (libproc2) and arch atm. Some hint about possible issues?

palinek commented 1 year ago

Some hint about possible issues?

Just check if all child processes of lxqt-session are gracefully terminated upon termination of lxqt-session.

tsujan commented 1 year ago

This should work:

  1. Check FeatherPad → Preferences → File → Start with files of last window.
  2. Open a FeatherPad window before logging out, open a file in it and put the cursor at some position inside the text.
  3. Log out without closing that window.
  4. Log in and run FeatherPad from Main Menu.

Then the file should be opened in it and the cursor position should be remembered. If not, something is wrong with the session.

stefonarch commented 1 year ago

On X11 this test has passed well. But on wayland (wayfire) lxqt-session (which I use always) dumps core now:


       Boot ID: 6b8044b79179459b8552434af42f6260
    Machine ID: 837f7352e32d4661965bf2173a1c4840
      Hostname: archlinux
       Storage: /var/lib/systemd/coredump/core.lxqt-session.1000.6b8044b79179459b8552434af42f6260.9578.1673286357000000.zst (present)
  Size on Disk: 1.1M
       Message: Process 9578 (lxqt-session) of user 1000 dumped core.

                Stack trace of thread 9578:
                #0  0x00007ff5ef9d6705 XkbUseExtension (libX11.so.6 + 0x91705)
                #1  0x00007ff5ef9d730a XkbGetAutoRepeatRate (libX11.so.6 + 0x9230a)
                #2  0x000055d8a363941f _ZN18SessionApplication20loadKeyboardSettingsERN4LXQt8SettingsE (lxqt-session + 0x2041f)
                #3  0x000055d8a363812f _ZN18SessionApplication7startupEv (lxqt-session + 0x1f12f)
                #4  0x000055d8a3627a91 _ZN18SessionApplication18qt_static_metacallEP7QObjectN11QMetaObject4CallEiPPv (lxqt-session + 0xea91)
                #5  0x00007ff5ee4b0bd0 _ZN7QObject5eventEP6QEvent (libQt5Core.so.5 + 0x2b0bd0)
                #6  0x00007ff5ef178b5c _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent (libQt5Widgets.so.5 + 0x178b5c)
                #7  0x00007ff5ee48cf98 _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent (libQt5Core.so.5 + 0x28cf98)
                #8  0x00007ff5ee48daa3 _ZN23QCoreApplicationPrivate16sendPostedEventsEP7QObjectiP11QThreadData (libQt5Core.so.5 + 0x28daa3)
                #9  0x00007ff5ee4d3ea8 n/a (libQt5Core.so.5 + 0x2d3ea8)
                #10 0x00007ff5eef1687b g_main_context_dispatch (libglib-2.0.so.0 + 0x5587b)
                #11 0x00007ff5eef6dc89 n/a (libglib-2.0.so.0 + 0xacc89)
                #12 0x00007ff5eef15132 g_main_context_iteration (libglib-2.0.so.0 + 0x54132)
                #13 0x00007ff5ee4d7c8c _ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE (libQt5Core.so.5 + 0x2d7c8c)
                #14 0x00007ff5ee48574c _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE (libQt5Core.so.5 + 0x28574c)
                #15 0x00007ff5ee490269 _ZN16QCoreApplication4execEv (libQt5Core.so.5 + 0x290269)
                #16 0x000055d8a362925e main (lxqt-session + 0x1025e)
                #17 0x00007ff5eda3c290 n/a (libc.so.6 + 0x23290)
                #18 0x00007ff5eda3c34a __libc_start_main (libc.so.6 + 0x2334a)
                #19 0x000055d8a36265f5 _start (lxqt-session + 0xd5f5)

                Stack trace of thread 9701:
                #0  0x00007ff5edb140bf __poll (libc.so.6 + 0xfb0bf)
                #1  0x00007ff5ea922d1d n/a (libQt5WaylandClient.so.5 + 0x72d1d)
                #2  0x00007ff5ee2e431a n/a (libQt5Core.so.5 + 0xe431a)
                #3  0x00007ff5eda9f8fd n/a (libc.so.6 + 0x868fd)
                #4  0x00007ff5edb21a60 n/a (libc.so.6 + 0x108a60)

                Stack trace of thread 9703:
                #0  0x00007ff5eda9c4b6 n/a (libc.so.6 + 0x834b6)
                #1  0x00007ff5eda9efd4 pthread_cond_timedwait (libc.so.6 + 0x85fd4)
                #2  0x00007ff5ee2eb744 _ZN14QWaitCondition4waitEP6QMutex14QDeadlineTimer (libQt5Core.so.5 + 0xeb744)
                #3  0x00007ff5ee2f01fc _ZN14QWaitCondition4waitEP6QMutexm (libQt5Core.so.5 + 0xf01fc)
                #4  0x000055d8a3640b54 _ZN10ProcReaper3runEv (lxqt-session + 0x27b54)
                #5  0x00007ff5ee2e431a n/a (libQt5Core.so.5 + 0xe431a)
                #6  0x00007ff5eda9f8fd n/a (libc.so.6 + 0x868fd)
                #7  0x00007ff5edb21a60 n/a (libc.so.6 + 0x108a60)

                Stack trace of thread 9702:
                #0  0x00007ff5edb140bf __poll (libc.so.6 + 0xfb0bf)
                #1  0x00007ff5ea922d1d n/a (libQt5WaylandClient.so.5 + 0x72d1d)
                #2  0x00007ff5ee2e431a n/a (libQt5Core.so.5 + 0xe431a)
                #3  0x00007ff5eda9f8fd n/a (libc.so.6 + 0x868fd)
                #4  0x00007ff5edb21a60 n/a (libc.so.6 + 0x108a60)

                Stack trace of thread 9700:
                #0  0x00007ff5edb140bf __poll (libc.so.6 + 0xfb0bf)
                #1  0x00007ff5eef6dbef n/a (libglib-2.0.so.0 + 0xacbef)
                #2  0x00007ff5eef15132 g_main_context_iteration (libglib-2.0.so.0 + 0x54132)
                #3  0x00007ff5ee4d7c8c _ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE (libQt5Core.so.5 + 0x2d7c8c)
                #4  0x00007ff5ee48574c _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE (libQt5Core.so.5 + 0x28574c)
                #5  0x00007ff5ee2e724f _ZN7QThread4execEv (libQt5Core.so.5 + 0xe724f)
                #6  0x00007ff5ef7a5cba n/a (libQt5DBus.so.5 + 0x23cba)
                #7  0x00007ff5ee2e431a n/a (libQt5Core.so.5 + 0xe431a)
                #8  0x00007ff5eda9f8fd n/a (libc.so.6 + 0x868fd)
                #9  0x00007ff5edb21a60 n/a (libc.so.6 + 0x108a60)
                ELF object binary architecture: AMD x86-64
tsujan commented 1 year ago

@stefonarch, according to your backtrace, the crash happened in SessionApplication::loadKeyboardSettings(), but this method isn't called under Wayland: the code calls it only when the platform name is "xcb".

I have a feeling that the problem you encountered may have another cause.

stefonarch commented 1 year ago

I only can tell that lxqt-session from master branch worked always fine (btw I just found the reason why it crashed on suspend: "lock screen before suspend" was checked) but this branch segfaults on wayfire.

Here the output after where, gdb wasn't installed:

Core was generated by `lxqt-session'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007ffa0a4d0705 in XkbUseExtension () from /usr/lib/libX11.so.6
[Current thread is 1 (Thread 0x7ffa081398c0 (LWP 12779))]
(gdb) where
#0  0x00007ffa0a4d0705 in XkbUseExtension () at /usr/lib/libX11.so.6
#1  0x00007ffa0a4d130a in XkbGetAutoRepeatRate () at /usr/lib/libX11.so.6
#2  0x000056434348b41f in SessionApplication::loadKeyboardSettings(LXQt::Settings&)
    (this=0x7ffe995099c0, settings=...)
    at /home/stef/git/lxqt/lxqt-session/lxqt-session/src/sessionapplication.cpp:186
#3  0x000056434348a12f in SessionApplication::startup() (this=0x7ffe995099c0)
    at /home/stef/git/lxqt/lxqt-session/lxqt-session/src/sessionapplication.cpp:80
#4  0x0000564343479a91 in SessionApplication::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)
    (_o=0x7ffe995099c0, _c=QMetaObject::InvokeMetaMethod, _id=0, _a=0x56434547c918)
    at /home/stef/git/lxqt/lxqt-session/build/lxqt-session/lxqt-session_autogen/UVLADIE3JM/moc_sessionapplication.cpp:72
#5  0x00007ffa08eb0bd0 in QObject::event(QEvent*) () at /usr/lib/libQt5Core.so.5
#6  0x00007ffa09b78b5c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () at /usr/lib/libQt5Widgets.so.5
#7  0x00007ffa08e8cf98 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () at /usr/lib/libQt5Core.so.5
#8  0x00007ffa08e8daa3 in QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) ()
    at /usr/lib/libQt5Core.so.5
#9  0x00007ffa08ed3ea8 in  () at /usr/lib/libQt5Core.so.5
#10 0x00007ffa0991687b in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#11 0x00007ffa0996dc89 in  () at /usr/lib/libglib-2.0.so.0
#12 0x00007ffa09915132 in g_main_context_iteration () at /usr/lib/libglib-2.0.so.0
#13 0x00007ffa08ed7c8c in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/lib/libQt5Core.so.5
#14 0x00007ffa08e8574c in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/lib/libQt5Core.so.5
#15 0x00007ffa08e90269 in QCoreApplication::exec() () at /usr/lib/libQt5Core.so.5
#16 0x000056434347b25e in main(int, char**) (argc=1, argv=0x7ffe99509b58)
    at /home/stef/git/lxqt/lxqt-session/lxqt-session/src/main.cpp:73
tsujan commented 1 year ago

Oh, problem solved: the branch is old.

You can get the patch (https://patch-diff.githubusercontent.com/raw/lxqt/lxqt-session/pull/456.patch) and apply it to the latest git.

stefonarch commented 1 year ago

Works now, thanks! Will later test session closing.

palinek commented 1 year ago

Oh, problem solved: the branch is old.

Yes, sorry for that. PR is rebased now.

JonathanVQP commented 1 year ago

I just tried the 456.patch on the latest git and it cmaked fine. It crashes when I did a make and gave a fataler error: lxqt-session/src/procreaper.cpp:35:12: fatal error: proc/readproc.h No such file or directory. # include <proc/readproc.h>