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

--- Comment #6 from Sanfod Rockowitz <rockow...@minsoft.com> ---
I have made extensive extensive changes to libddcutil in branch 2.2.1-dev to
detect API usage errors and diagnose display lock deadlocks.

A key problem is that calling ddca_redetect_displays() while display watch is
active can produce invalid states.  Prior to release 2.2.0, display change
detection just informed the client by callback that the display configuration
had changed, leaving it to the client to call ddca_redetect_displays() which
tells libddcutil to discard everything it knows about connected displays.  As
of release 2.2.0, display change detection updates libddcuti's internal tables
and informs the client by callback what has changed.  The client should not
need to call ddca_redetect_displays().

A key check is preventing ddca_redetect_displays() from executing with callback
threads are active.   This can lead to  corrupt data structures.  
Callback functions run in their own thread and libddcutil does not block until
the callback completes - otherwise an errant callback function could hang
display watch detection.  Unfortunately, I don't see a way to distinguish using
the glib API between callbacks that are still executing, and which should bock
ddca_redetect_displays(), and ones that have actually died.  So at best what
happens is that an error message is written to the system log warning the
ddca_redetect_displays() appears to be called when callback threads are
executing.  But again, all this convoluted and imperfect logic can be avoided
by avoiding use of ddca_redetect_displays()

If deadlocks persist, please run with the following settings in configuration
file ddcutilrc: 

options: --ts --tid   
options: --ts --trace api --trcfile display_lock.c
options: --trace-to-syslog-only
options: --trcfunc add_open_display_for_current_thread --trcfunc
remove_open_display_for_current_thread
options: --trcfunc ddc_close_all_displays_for_current_thread
options: --trcfunc unlock_all_displays_for_current_thread
options: --trcfunc dw_execute_callback_func

Output to the system log will be voluminous.  Error messages in the system log
may immediately indicate the problem.  Otherwise leave it to me to examine the
output.

Unfortunately, I am traveling with only my laptop, so I am unable to test all
these changes by attaching and detaching monitors. I also expect to be
unavailable for the next several days.  But I wanted  to give people the
opportunity to test with them.

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

Reply via email to