https://bugs.kde.org/show_bug.cgi?id=514595

--- Comment #5 from [email protected] <[email protected]> 
---
Same crash here on Fedora 44, which still ships ddcutil 2.2.1, so it doesn't
have the upstream fix from ddcutil#556. I'm adding it in case it helps users of
distros that haven't updated yet.

Versions: powerdevil 6.7.5, Plasma 6.7.5, Frameworks 6.31.0, Qt 6.11.2,
ddcutil/libddcutil 2.2.1, Wayland.

Trigger: an HDMI KVM switch. Switching away and back drops the connector for
about 1-2 s. powerdevil crashes on roughly 1 in 8 switches (3 of 24 in two
weeks).

The log shows a race between powerdevil's main thread and BrightnessWorker:

+0.00  compositor: "There are no outputs - creating placeholder screen"
+0.90  [worker] (ddc_open_display) Delay before rechecking attribute status:
Sleeping for 1000 milliseconds
+1.15  Removing connected display on bus 3
+1.15  DDCA_EVENT_DISPLAY_DISCONNECTED, card1-HDMI-A-1, dref:
DDCA_Display_Ref[1]
+1.88  Adding connected display with bus 3
+1.90  [worker] ddc_packet_io.c:332: ddc_open_display: Assertion `bus_info'
failed.
+2.42  DDCA_EVENT_DISPLAY_CONNECTED, card1-HDMI-A-1, dref: DDCA_Display_Ref[2]

Crashing thread: BrightnessWorker::ddcSetBrightness -> ddca_open_display2 ->
ddci_open_display3 -> ddc_open_display -> __assert_fail
Main thread at the same moment: DDCutilPrivateSingleton::removeDisplay ->
DDCutilDisplay::~DDCutilDisplay -> QThread::wait

So the worker began opening dref[1] before the disconnect and slept for 1 s
inside ddc_open_display. Meanwhile the main thread removed that display and was
waiting for the worker. The worker then woke up holding a stale ref.

The ddcutil fix turns the assert into an error return, but powerdevil still
hands a display ref to the worker while removeDisplay is tearing it down. Could
powerdevil cancel or invalidate pending brightness work in removeDisplay, or
have the worker check that its display is still valid before calling
ddca_open_display2? That would stop the crash on distros with older ddcutil,
and it would avoid relying on what libddcutil does with a stale ref.

Workaround for anyone else hitting this: POWERDEVIL_NO_DDCUTIL=1 in a systemd
user override for plasma-powerdevil.service. This disables DDC brightness
control.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to