ddcutil icon indicating copy to clipboard operation
ddcutil copied to clipboard

Program Hangs after --async

Open jcstill opened this issue 5 years ago • 7 comments

After using --async, all subsequent commands with or without --async spawn second process and whole program hangs. I am not sure if the second process is normal as I only noticed it after having to forcefully kill ddcutil with sudo kill -9 PID.

Version 0.8.6: ddcutil_HEADSHOTS

Version 0.9.9: ddcutil_HEADSHOTS_2

I only got verbose outputs after this started happening (just the detect command): Version 0.8.6: ddcutil_verbose_detect

Version 0.9.9: ddcutil_verbose_detect_2

Unfortunately the process is in state D (uninterruptible sleep). I assume a reboot will get rid of these and fix the problem altogether, though haven't tried yet. I will reboot and update.

jcstill avatar Jul 18 '20 07:07 jcstill

Thank you for reporting the hang. There have been similar reports in the past, but never have been able to reproduce the problem.  Are you able to reproduce it?  If so, does it occur when you invoke ddcutil without using sudo?

If you can reproduce the problem, try usingrecently added option http://www.ddcutil.com/release_notes/ "--timeout-i2c-io".  This option causes most I2C IO calls to time out instead of waiting forever.  If timeout occurs, a debug message is issued to draw attention to the event.

I'm not sure what you're getting at regarding the "--verbose" option.  It should cause the settings information to be shown at the start of any command with that option.

-- Sanford

On 7/18/20 3:21 AM, Jacob Still wrote:

After using |--async|, all subsequent commands with or without |--async| spawn second process and whole program hangs. I am not sure if the second process is normal as I only noticed it after having to forcefully kill ddcutil with |sudo kill -9 PID|.

Version 0.8.6: ddcutil_HEADSHOTS https://user-images.githubusercontent.com/31301328/87847215-35645a80-c88b-11ea-8027-34ca34610a48.png

Version 0.9.9: ddcutil_HEADSHOTS_2 https://user-images.githubusercontent.com/31301328/87847216-35fcf100-c88b-11ea-9785-77158c43cd44.png

I only got verbose outputs after this started happening (just the detect command): Version 0.8.6: ddcutil_verbose_detect https://user-images.githubusercontent.com/31301328/87847334-3944ac80-c88c-11ea-91e3-b47b1a5febe4.png

Version 0.9.9: ddcutil_verbose_detect_2 https://user-images.githubusercontent.com/31301328/87847335-39dd4300-c88c-11ea-80a3-621aed0ae4fd.png

Unfortunately the process is in state D (uninterruptible sleep). I assume a reboot will get rid of these and fix the problem altogether, though haven't tried yet. I will reboot and update.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rockowitz/ddcutil/issues/131, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMGY3SC5MIAMZYEXX72ECDR4FEP7ANCNFSM4O7RH6MA.

rockowitz avatar Jul 18 '20 21:07 rockowitz

Rebooting fixed the issue, as expected. However, the kernel sat waiting for those processes to end for about 15 min before I decided to cut power.

As for the verbose thing, I meant that I did not run the program with verbose before the hang, so there is no before/after reference for this machine (not sure if it matters).

I am not sure if this occurs without sudo, as I get permission denied errors. I will test if this occurs running from the root user as well.

I was able to reproduce this, though I did not document and it was almost exactly the same as:

Correct. If I call this:

/usr/bin/ddcutil -d 1 setvcp 10 50 &
/usr/bin/ddcutil -d 2 setvcp 10 50 &

The second command will hang.

However, changing it to this:

/usr/bin/ddcutil -d 1 setvcp 10 50
sleep .1
/usr/bin/ddcutil -d 2 setvcp 10 50

Has resulted in no hangs when calling the batch command.

Originally posted by @nvahalik in https://github.com/rockowitz/ddcutil/issues/86#issuecomment-508773371

Ill do some more testing and document it.

jcstill avatar Jul 19 '20 00:07 jcstill

I think I may have been incorrect in assuming this was caused by async. It seems that async works as intended:

note: all file with "baseline" were run before running async every run as non-priveleged user looks identical to detect_baseline_noprivs.txt every run as root user looks identical to the respective sudo run

command result
ddcutil -v detect detect_baseline_noprivs.txt
sudo ddcutil -v detect detect_baseline_sudo.txt
sudo ddcutil -v -d 2 setvcp 10 75 setvcp_baseline_sudo.txt
sudo ddcutil -v -d 2 --timeout-i2c-io setvcp 10 75 setvcp_timeout-i2c-io_sudo.txt
sudo ddcutil -v --async -d 2 setvcp 10 75 setvcp_async_baseline_sudo.txt
ddcutil -v --async --timeout-i2c-io -d 2 setvcp 10 75 setvcp_async_timeout_sudo.txt

Basically everything appears to be working as normal. Here is the interrogate: interrogate_baseline_sudo.txt

I think this is actually the same problem as #86.

This works in a script (ran with root privs):

ddcutil -v -d 2 setvcp 10 $1
ddcutil -v -d 2 setvcp 12 $1

This causes the hang:

ddcutil -v --timeout-i2c-io -d 2 setvcp 10 $1 &
ddcutil -v --timeout-i2c-io -d 2 setvcp 12 $1 &

timeout_hang_output timeout_hang_ps

I will update with --async and also adding a sleep similar to what @nvahalik did to test further.

This is the script I am using:

#!/bin/bash

# Tested, Working
#ddcutil -v -d 2 setvcp 10 $1
#ddcutil -v -d 2 setvcp 12 $1

#--------------------------------------------------------

# Tested, Causes Hang
#ddcutil -v --timeout-i2c-io -d 2 setvcp 10 $1 &
#ddcutil -v --timeout-i2c-io -d 2 setvcp 12 $1 &

# Untested
ddcutil -v --timeout-i2c-io -d 2 setvcp 10 $1 &
sleep 1
ddcutil -v --timeout-i2c-io -d 2 setvcp 12 $1 &

#--------------------------------------------------------

# Untested
#ddcutil -v --async --timeout-i2c-io -d 2 setvcp 10 $1 &
#ddcutil -v --async --timeout-i2c-io -d 2 setvcp 12 $1 &

# Untested
#ddcutil -v --async --timeout-i2c-io -d 2 setvcp 10 $1 &
#sleep 1
#ddcutil -v --async --timeout-i2c-io -d 2 setvcp 12 $1 &

#--------------------------------------------------------

# Untested
#ddcutil -v --async -d 2 setvcp 10 $1 &
#ddcutil -v --async -d 2 setvcp 12 $1 &

# Untested
#ddcutil -v --async -d 2 setvcp 10 $1 &
#sleep 1
#ddcutil -v --async -d 2 setvcp 12 $1 &

jcstill avatar Jul 19 '20 03:07 jcstill

I tested all the cases in the script and here are the results:

async Hang: async_hang_output This one was weird as the first time I ran it, nothing happened (display didn't change) and it did not hang. But, the second time hung: async_hang_ps

async+sleep Hang async+sleep_hang_output async+sleep_hang_ps

async+timeout Hang: async+timeout_hang_output async+timeout_hang_ps

timeout Hang: timeout_hang_output timeout_hang_ps

timeout+sleep Hang: timeout+sleep_hang_output timeout+sleep_hang_ps

sleep Hang:

ddcutil -v -d 2 setvcp 10 $1 &
sleep 1
ddcutil -v -d 2 setvcp 12 $1 &

sleep_hang_output sleep_hang_ps

Wokring:

async+timeout+sleep Works: async+timeout+sleep_works_output

jcstill avatar Jul 19 '20 04:07 jcstill

Jacob,

Thank you for the detailed tests.  I will review what you've observed.

One minor thing to point out is that you can run ddcutil as a non-root user.  From the interrogate output, I see that group i2c exists and the /dev/i2c devices are assigned to that group, which has RW permission for the devices.  All you need to do is add your user to that group.

Alternatively, and you can simply "sudo chmod a+rw /dev/i2c*", though you'll have to do this every time you log on.

Regards, Sanford

On 7/18/20 8:59 PM, Jacob Still wrote:

Rebooting fixed the issue, as expected. However, the kernel sat waiting for those processes to end for about 15 min before I decided to cut power.

As for the verbose thing, I meant that I did not run the program with verbose before the hang, so there is no before/after reference for this machine (not sure if it matters).

I am not sure if this occurs without sudo, as I get permission denied errors. I will test if this occurs running from the root user as well.

I was able to reproduce this, though I did not document and it was almost exactly the same as:

Correct. If I call this:

|/usr/bin/ddcutil -d 1 setvcp 10 50 & /usr/bin/ddcutil -d 2 setvcp
10 50 & |

The second command will hang.

However, changing it to this:

|/usr/bin/ddcutil -d 1 setvcp 10 50 sleep .1 /usr/bin/ddcutil -d 2
setvcp 10 50 |

Has resulted in no hangs when calling the batch command.

/Originally posted by @nvahalik https://github.com/nvahalik in #86 (comment) https://github.com/rockowitz/ddcutil/issues/86#issuecomment-508773371/

Ill do some more testing and document it.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rockowitz/ddcutil/issues/131#issuecomment-660565826, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMGY3TRGG3Y3GWEZM7H5BLR4JAOXANCNFSM4O7RH6MA.

rockowitz avatar Jul 20 '20 03:07 rockowitz

One minor thing to point out is that you can run ddcutil as a non-root user. From the interrogate output, I see that group i2c exists and the /dev/i2c devices are assigned to that group, which has RW permission for the devices. All you need to do is add your user to that group.

I guess that completely flew over my head. Makes perfect sense though. Thanks.

jcstill avatar Jul 20 '20 04:07 jcstill

What your tests show is that the hang happens when running 2 instances of ddcutil in parallel (& at the end of command), not when running them sequentially.  Based on the prior email and this one, it's unclear whether inserting a sleep between the 2 sequential ddcutil calls is unnecessary.

Please run a failure case with the following command options: "--trace i2c --tid --ts".  This will turn on tracing in the i2c layer, and include the thread id and timestamp.

If you can, please run the tests using the current 1.0.0 branch. I've made minor changes to tracing that should make the output easier to analyze.

Regards, Sanford

On 7/18/20 11:34 PM, Jacob Still wrote:

I think I may have been incorrect in assuming this was caused by |async|. It seems that |async| works as intended:

note: all file with "baseline" were run before running |async|
every run as non-priveleged user looks identical to
|detect_baseline_noprivs.txt|
every run as root user looks identical to the respective |sudo| run

command result |ddcutil -v detect| detect_baseline_noprivs.txt https://github.com/rockowitz/ddcutil/files/4943153/detect_baseline_noprivs.txt

|sudo ddcutil -v detect| detect_baseline_sudo.txt https://github.com/rockowitz/ddcutil/files/4943154/detect_baseline_sudo.txt

|sudo ddcutil -v -d 2 setvcp 10 75| setvcp_baseline_sudo.txt https://github.com/rockowitz/ddcutil/files/4943159/setvcp_baseline_sudo.txt

|sudo ddcutil -v -d 2 --timeout-i2c-io setvcp 10 75| setvcp_timeout-i2c-io_sudo.txt https://github.com/rockowitz/ddcutil/files/4943160/setvcp_timeout-i2c-io_sudo.txt

|sudo ddcutil -v --async -d 2 setvcp 10 75| setvcp_async_baseline_sudo.txt https://github.com/rockowitz/ddcutil/files/4943157/setvcp_async_baseline_sudo.txt

|ddcutil -v --async --timeout-i2c-io -d 2 setvcp 10 75| setvcp_async_timeout_sudo.txt https://github.com/rockowitz/ddcutil/files/4943158/setvcp_async_timeout_sudo.txt

Basically everything appears to be working as normal. Here is the interrogate: interrogate_baseline_sudo.txt https://github.com/rockowitz/ddcutil/files/4943175/interrogate_baseline_sudo.txt

I think this is actually the same problem as #86 https://github.com/rockowitz/ddcutil/issues/86.

This works in a script (ran with root privs):

ddcutil -v -d 2 setvcp 10$1 ddcutil -v -d 2 setvcp 12$1

This causes the hang:

ddcutil -v --timeout-i2c-io -d 2 setvcp 10$1 & ddcutil -v --timeout-i2c-io -d 2 setvcp 12$1 &

timeout_hang_output https://user-images.githubusercontent.com/31301328/87866280-a6138180-c934-11ea-95b0-26365bca07ca.png timeout_hang_ps https://user-images.githubusercontent.com/31301328/87866281-a6ac1800-c934-11ea-9534-6af75330a9e4.png

I will update with |--async| and also adding a |sleep| similar to what @nvahalik https://github.com/nvahalik did to test further.

This is the script I am using:

#!/bin/bash

Tested, Working

#ddcutil -v -d 2 setvcp 10 $1 #ddcutil -v -d 2 setvcp 12 $1

#--------------------------------------------------------

Tested, Causes Hang

#ddcutil -v --timeout-i2c-io -d 2 setvcp 10 $1 & #ddcutil -v --timeout-i2c-io -d 2 setvcp 12 $1 &

Untested

ddcutil -v --timeout-i2c-io -d 2 setvcp 10$1 & sleep 1 ddcutil -v --timeout-i2c-io -d 2 setvcp 12$1 &

#--------------------------------------------------------

Untested

#ddcutil -v --async --timeout-i2c-io -d 2 setvcp 10 $1 & #ddcutil -v --async --timeout-i2c-io -d 2 setvcp 12 $1 &

Untested

#ddcutil -v --async --timeout-i2c-io -d 2 setvcp 10 $1 & #sleep 1 #ddcutil -v --async --timeout-i2c-io -d 2 setvcp 12 $1 &

#--------------------------------------------------------

Untested

#ddcutil -v --async -d 2 setvcp 10 $1 & #ddcutil -v --async -d 2 setvcp 12 $1 &

Untested

#ddcutil -v --async -d 2 setvcp 10 $1 & #sleep 1 #ddcutil -v --async -d 2 setvcp 12 $1 &

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rockowitz/ddcutil/issues/131#issuecomment-660580422, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADMGY3RICQ2TFZVCIKVHCTTR4JSVPANCNFSM4O7RH6MA.

rockowitz avatar Jul 21 '20 04:07 rockowitz