Comment 58 for bug 1794292

Test Case
=========

For example, this Bionic Server VM:

 $ uvt-simplestreams-libvirt sync release=bionic arch=amd64
 $ uvt-kvm create --memory 2048 --cpu 2 --disk 8 bionic-lp1794292 release=bionic arch=amd64

 $ uvt-kvm ssh bionic-lp1794292

It has a virtual Cirrus VGA adapter:

 $ lspci | grep VGA
 00:02.0 VGA compatible controller: Cirrus Logic GD 5446

Install its DRM module, which should not load by default:

 $ sudo apt-get -y install linux-modules-extra-$(uname -r)
 $ echo 'blacklist cirrus' | sudo tee /etc/modprobe.d/blacklist-cirrus.conf

Update GRUB to use the default console (remove 'console=' options)

 $ sudo vim /etc/default/grub /etc/default/grub.d/*
 $ sudo update-grub
 $ sudo reboot

 $ cat /proc/cmdline
 BOOT_IMAGE=/boot/vmlinuz-4.15.0-47-generic root=UUID=d7976e5d-71dc-4f7e-82d6-a2c292e0975e ro quiet splash vt.handoff=1

Upon boot, only the FB device is availble, not DRI/DRM:

 $ ls -l /dev/fb0
 crw-rw---- 1 root video 29, 0 Apr 10 22:43 /dev/fb0

 $ ls -l /dev/dri
 ls: cannot access '/dev/dri': No such file or directory

The modules exist but are not loaded:

 $ lspci -s 00:02.0 -k
 00:02.0 VGA compatible controller: Cirrus Logic GD 5446
  Subsystem: Red Hat, Inc. QEMU Virtual Machine
  Kernel modules: cirrusfb, cirrus

 $ lsmod | grep cirrus
 $

This is the test case. Essentially:

 1) start plymouthd
 2) wait the default device timeout (5 seconds), so it detects '/dev/fb0'
 3) show splash, so it activates keyboard
 4) load module, so it detects '/dev/dri/card0'
 5) deactivate, so it deactivates keyboard and segfaults (or not)

  Give it a little time between each command to process events.

 sudo plymouthd --no-daemon --debug --kernel-command-line=splash &
 sleep 10
 sudo plymouth --show-splash
 sleep 10
 sudo modprobe cirrus
 sleep 10
 sudo plymouth deactivate
 <segfaults in a few seconds>

  With the same stack trace:

 #0 0x00007fdf0ef68f09 in ply_renderer_set_handler_for_input_source (renderer=<optimized out>, input_source=0x5636eaefc2a0, handler=0x0, user_data=0x0) at ply-renderer.c:406
 #1 0x00007fdf0ef62cbf in ply_keyboard_stop_watching_for_renderer_input (keyboard=0x5636eaefc6a0) at ply-keyboard.c:319
 #2 ply_keyboard_stop_watching_for_input (keyboard=keyboard@entry=0x5636eaefc6a0) at ply-keyboard.c:406
 #3 0x00007fdf0ef6221b in ply_device_manager_deactivate_keyboards (manager=0x5636eaeff6d0) at ply-device-manager.c:976
 #4 0x00005636e92d3ec3 in on_deactivate (state=0x7fff1c458390, deactivate_trigger=<optimized out>) at main.c:1361
 #5 0x00005636e92cdb9b in ply_boot_connection_on_request (connection=0x5636eaf12360) at ply-boot-server.c:504
 #6 0x00007fdf0f177fbe in ply_event_loop_handle_met_status_for_source (status=<optimized out>, source=0x5636eaf11970, loop=0x5636eaefa3a0) at ply-event-loop.c:1034
 #7 ply_event_loop_process_pending_events (loop=loop@entry=0x5636eaefa3a0) at ply-event-loop.c:1279
 #8 0x00007fdf0f178480 in ply_event_loop_run (loop=0x5636eaefa3a0) at ply-event-loop.c:1310
 #9 0x00005636e92cb514 in main (argc=4, argv=0x7fff1c459588) at main.c:2398

The version in -proposed does not have these lines in the module load step.

 [ply-device-manager.c:345] on_udev_event:got remove event for device fb0
 [ply-renderer.c:92] ply_renderer_free:Unloading renderer backend plugin