]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: kill plymouthd after initrd transition if it's still running
authorFrantisek Sumsal <frantisek@sumsal.cz>
Mon, 5 Sep 2022 19:02:25 +0000 (21:02 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 5 Sep 2022 23:33:02 +0000 (08:33 +0900)
Until now using the INTERACTIVE_DEBUG=yes stuff together with sanitizers
was almost impossible, since the console kept eating up our inputs or
not responding at all. After a painful day of debugging I noticed that
if we use a shell script in the initrd -> root transition, we might end up
with a plymouthd still running, which kept screwing with the tty.

E.g. with initrd -> wrapper -> systemd transition, where the `wrapper`
is a simple script:

```
exec -- /usr/lib/systemd/systemd "$@"
```

we'd end up with a stray plymouthd process after the bootup:

```
 1     0     440       2  20   0      0     0 worker I    ?          0:00 [kworker/5:2-ata_sff]
 1     0     453       2  20   0      0     0 worker I    ?          0:00 [kworker/9:2-rcu_gp]
 5     0     456       1  20   0   7252  1960 do_epo S    ?          0:00 @usr/sbin/plymouthd --mode=boot --pid-file=/run/plymouth/pid --attach-to-session
```

After killing it, the tty works finally as expected.

test/test-functions

index c8b0cef1f23e66446b77e88d9d6e02200cdb16c2..6215ec1cc64f5a22d1d8d8778ace6ada98eefe6f 100644 (file)
@@ -179,6 +179,7 @@ BASICTOOLS=(
     head
     ionice
     ip
+    killall
     ldd
     ln
     loadkeys
@@ -1794,6 +1795,26 @@ install_debug_tools() {
             image_install resize
             echo "resize" >>"$initdir/etc/profile"
         fi
+
+        # Sometimes we might end up with plymouthd still running (especially
+        # with the initrd -> asan_wrapper -> systemd transition), which will eat
+        # our inputs and make debugging via tty impossible. Let's fix this by
+        # killing plymouthd explicitly for the interactive sessions.
+        # Note: we can't use pkill/pidof/etc. here due to a bug in libasan, see:
+        #   - https://github.com/llvm/llvm-project/issues/49223
+        #   - https://bugzilla.redhat.com/show_bug.cgi?id=2098125
+        local plymouth_unit="${initdir:?}/etc/systemd/system/kill-plymouth.service"
+        cat >"$plymouth_unit" <<EOF
+[Unit]
+After=multi-user.target
+
+[Service]
+ExecStart=sh -c 'killall --verbose plymouthd || :'
+
+[Install]
+WantedBy=multi-user.target
+EOF
+        "${SYSTEMCTL:?}" enable --root "${initdir:?}" kill-plymouth.service
     fi
 }