Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SDDM hanging when shutting down Plasma Wayland session #1515

Closed
wants to merge 4 commits into from

Conversation

zzag
Copy link

@zzag zzag commented Feb 15, 2022

If the sddm-helper receives SIGTERM or the session process terminates
with non zero exit code, delaying restarting display.

The main issue with restarting display at shutdown is that sddm can hang
when trying to get display from Xorg. This is the main reason why shutdown
takes so long with plasma wayland session.

fixes #1476

SignalHandler::initialize() must be called otherwise signals won't be
processed and helpers can crash when they receive SIGTERM.
If xorg stops, sddm will try to create a new display, however this can
create issues at shutdown where systemd tries to kill all processes in
the cgroup.

This change changes the kill mode of sddm to mixed. With that mode, sddm
will be able to terminate the display itself. If sddm fails to do so
within reasonable interval, systemd will start killing processes in the
cgroup.
If sddm-helper misbehaves at shutdown, e.g. crashes, sddm may try to
restart display, which can end up in shutdown getting stuck.
@zzag zzag force-pushed the work/zzag/wayland-shut-down branch from 94e2830 to 3485204 Compare February 15, 2022 18:56
When the computer shuts down, sddm can try to restart Xorg and hang when
reading the display from Xorg.

This change intends to mitigate that issue by making sddm delaying
stopping display if the sddm-helper's exit code is not 0.

If the exit code is 0, the user has most likely logged out, and therefore
it should be relatively safe to restart display. Otherwise wait a second
before attempting to restart display.
@zzag zzag force-pushed the work/zzag/wayland-shut-down branch from 3485204 to 1204ef8 Compare February 15, 2022 19:00
@tpgxyz
Copy link
Contributor

tpgxyz commented Feb 18, 2022

@zzag Here are couple errors found when building from git with PRs 1489, 1494, 1506, 1511

FAILED: src/helper/CMakeFiles/sddm-helper-start-x11user.dir/HelperStartX11User.cpp.o 
/usr/bin/clang++ -DHAVE_JOURNALD -DHAVE_SYSTEMD -DNDEBUG -DQT_CORE_LIB -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_DEBUG -DQT_NO_FOREACH -DSDDM_VERSION=\"0.19.0\" -DUSE_PAM -I/builddir/build/BUILD/sddm-0.19.0-20220211/build/src/helper -I/builddir/build/BUILD/sddm-0.19.0-20220211/src/helper -I/builddir/build/BUILD/sddm-0.19.0-20220211/build/src/helper/sddm-helper-start-x11user_autogen/include -I/builddir/build/BUILD/sddm-0.19.0-20220211/src/common -I/builddir/build/BUILD/sddm-0.19.0-20220211/src/auth -I/builddir/build/BUILD/sddm-0.19.0-20220211/build/src/common -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/./mkspecs/linux-clang -Os -fomit-frame-pointer -g3 -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -flto -O2 -Os -fomit-frame-pointer -g3 -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -flto   -Wall -std=c++11 -fPIC -MD -MT src/helper/CMakeFiles/sddm-helper-start-x11user.dir/HelperStartX11User.cpp.o -MF src/helper/CMakeFiles/sddm-helper-start-x11user.dir/HelperStartX11User.cpp.o.d -o src/helper/CMakeFiles/sddm-helper-start-x11user.dir/HelperStartX11User.cpp.o -c /builddir/build/BUILD/sddm-0.19.0-20220211/src/helper/HelperStartX11User.cpp
/builddir/build/BUILD/sddm-0.19.0-20220211/src/helper/HelperStartX11User.cpp:44:26: error: 'initialize' is a private member of 'SDDM::SignalHandler'
    SDDM::SignalHandler::initialize();
                         ^
/builddir/build/BUILD/sddm-0.19.0-20220211/src/common/SignalHandler.h:48:21: note: declared private here
        static void initialize();
                    ^
1 error generated.
FAILED: src/helper/CMakeFiles/sddm-helper-start-wayland.dir/HelperStartWayland.cpp.o 
/usr/bin/clang++ -DHAVE_JOURNALD -DHAVE_SYSTEMD -DNDEBUG -DQT_CORE_LIB -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_DEBUG -DQT_NO_FOREACH -DSDDM_VERSION=\"0.19.0\" -DUSE_PAM -I/builddir/build/BUILD/sddm-0.19.0-20220211/build/src/helper -I/builddir/build/BUILD/sddm-0.19.0-20220211/src/helper -I/builddir/build/BUILD/sddm-0.19.0-20220211/build/src/helper/sddm-helper-start-wayland_autogen/include -I/builddir/build/BUILD/sddm-0.19.0-20220211/src/common -I/builddir/build/BUILD/sddm-0.19.0-20220211/src/auth -I/builddir/build/BUILD/sddm-0.19.0-20220211/build/src/common -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/./mkspecs/linux-clang -Os -fomit-frame-pointer -g3 -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -flto -O2 -Os -fomit-frame-pointer -g3 -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -flto   -Wall -std=c++11 -fPIC -MD -MT src/helper/CMakeFiles/sddm-helper-start-wayland.dir/HelperStartWayland.cpp.o -MF src/helper/CMakeFiles/sddm-helper-start-wayland.dir/HelperStartWayland.cpp.o.d -o src/helper/CMakeFiles/sddm-helper-start-wayland.dir/HelperStartWayland.cpp.o -c /builddir/build/BUILD/sddm-0.19.0-20220211/src/helper/HelperStartWayland.cpp
/builddir/build/BUILD/sddm-0.19.0-20220211/src/helper/HelperStartWayland.cpp:42:26: error: 'initialize' is a private member of 'SDDM::SignalHandler'
    SDDM::SignalHandler::initialize();
                         ^
/builddir/build/BUILD/sddm-0.19.0-20220211/src/common/SignalHandler.h:48:21: note: declared private here
        static void initialize();
                    ^
1 error generated.
FAILED: src/helper/CMakeFiles/sddm-helper.dir/HelperApp.cpp.o 
/usr/bin/clang++ -DHAVE_JOURNALD -DHAVE_SYSTEMD -DNDEBUG -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_NETWORK_LIB -DQT_NO_CAST_FROM_ASCII -DQT_NO_CAST_FROM_BYTEARRAY -DQT_NO_DEBUG -DQT_NO_FOREACH -DQT_QML_LIB -DSDDM_VERSION=\"0.19.0\" -DUSE_PAM -I/builddir/build/BUILD/sddm-0.19.0-20220211/build/src/helper -I/builddir/build/BUILD/sddm-0.19.0-20220211/src/helper -I/builddir/build/BUILD/sddm-0.19.0-20220211/build/src/helper/sddm-helper_autogen/include -I/builddir/build/BUILD/sddm-0.19.0-20220211/src/common -I/builddir/build/BUILD/sddm-0.19.0-20220211/src/auth -I/builddir/build/BUILD/sddm-0.19.0-20220211/build/src/common -isystem /usr/include/qt5 -isystem /usr/include/qt5/QtNetwork -isystem /usr/include/qt5/QtCore -isystem /usr/lib64/qt5/./mkspecs/linux-clang -isystem /usr/include/qt5/QtDBus -isystem /usr/include/qt5/QtQml -Os -fomit-frame-pointer -g3 -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -flto -O2 -Os -fomit-frame-pointer -g3 -gdwarf-4 -Wstrict-aliasing=2 -pipe -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fstack-protector-all --param=ssp-buffer-size=4 -flto   -Wall -std=c++11 -fPIC -MD -MT src/helper/CMakeFiles/sddm-helper.dir/HelperApp.cpp.o -MF src/helper/CMakeFiles/sddm-helper.dir/HelperApp.cpp.o.d -o src/helper/CMakeFiles/sddm-helper.dir/HelperApp.cpp.o -c /builddir/build/BUILD/sddm-0.19.0-20220211/src/helper/HelperApp.cpp
/builddir/build/BUILD/sddm-0.19.0-20220211/src/helper/HelperApp.cpp:56:24: error: 'initialize' is a private member of 'SDDM::SignalHandler'
        SignalHandler::initialize();
                       ^
/builddir/build/BUILD/sddm-0.19.0-20220211/src/common/SignalHandler.h:48:21: note: declared private here
        static void initialize();
                    ^
1 error generated.

@Kangie
Copy link
Contributor

Kangie commented Jun 11, 2022

I looked into rebasing these before I just built 'develop' to find my issue resolved - I'm not sure that this fix needs to be applied (but may still be valuable).

Those errors can easily be fixed by dropping d480c7e3a3c9e30ea9687d2b2f7d08304569fffd as the Signal Handler no longer needs to be initialised if the remaining changes are worth merging.

@zzag zzag closed this Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slow shutdown problems in kde plasma with sddm
3 participants