Subject: bug#483: eudev: eudev sometimes fails to generate initial hotplug events

From: David Kuehling <[email-masked]>
Date: Mon, 15 Jun 2020 17:08:38 +0200

Package: eudev
Version: 3.2.7-6
Severity: normal
File: /etc/init.d/eudev

Dear Maintainer,

eudev sometimes fails to generate the initial hotplug events for one of
my systems.  The symptoms are that many required kernel modules are
missing after boot (no sound, no 3-D acceleration).

The error is not determinstic.  Sometimes the system boots up
successfully and everything works.  Sometimes the system boots up and
essential kernel modules are missing.

Doing '/etc/init.d/eudev stop' followed by '/etc/init.d/eudev start'
corrects the issue (i.e. results in all modules being loaded).  The
issue can also be corrected by manually running 'udevadm trigger
--action=add'.

The actual root cause seems to be a race condition in the
/etc/init.d/eudev startup script: The script first starts eudev via
start-stop-daemon, then calls 'udevadm trigger --action=add'.

On the system in question, after modifying the script, adding 'sleep 1s'
after start-stop-daemon, the startup now succeeded all the (two) times I
tried.

Note that the system in question runs from a root partition that resides
on a NBD-devices, so startup times of eudev may be very different from a
normal HDD-based system, thereby amplifying the likelhood of the race.

I have no clear idea how a proper fix for that race would look like.
Clearly 'start-stop-daemon --background' does NOT wait for the daemon to
be operational and looks like the wrong approach.  Maybe running
start-stop-daemon without "--background" and depending on eudev's
"--daemon" option is better?  Does eudev support using
start-stop-daemon's --notify-await command?  Should we run 'udevadm
trigger' in a loop until it succeeds?

-- System Information:
Distributor ID:	Debian
Description:	Devuan GNU/Linux 3 (beowulf)
Release:	3
Codename:	beowulf
Architecture: x86_64

Kernel: Linux 4.19.0-9-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US:en (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled

Versions of packages eudev depends on:
ii  adduser      3.118
ii  debconf      1.5.71
ii  libblkid1    2.33.1-0.1+devuan1~beowulf2
ii  libc6        2.28-10
ii  libeudev1    3.2.7-6
ii  libkmod2     26-1
ii  libselinux1  2.8-1+b1
ii  lsb-base     10.2019051400
ii  procps       2:3.3.15-2+devuan1
ii  util-linux   2.33.1-0.1+devuan1~beowulf2

eudev recommends no packages.

eudev suggests no packages.

-- no debconf information