Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program Hangs after --async #131

Open
jcstill opened this issue Jul 18, 2020 · 7 comments
Open

Program Hangs after --async #131

jcstill opened this issue Jul 18, 2020 · 7 comments

Comments

@jcstill
Copy link

jcstill commented Jul 18, 2020

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.

@rockowitz
Copy link
Owner

rockowitz commented Jul 18, 2020 via email

@jcstill
Copy link
Author

jcstill commented Jul 19, 2020

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 #86 (comment)

Ill do some more testing and document it.

@jcstill
Copy link
Author

jcstill commented Jul 19, 2020

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
Copy link
Author

jcstill commented Jul 19, 2020

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

@rockowitz
Copy link
Owner

rockowitz commented Jul 20, 2020 via email

@jcstill
Copy link
Author

jcstill commented Jul 20, 2020

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.

@rockowitz
Copy link
Owner

rockowitz commented Jul 21, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants