You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When there is high throughput like running a loop to launch/kill app and at the same time getting syslog with another ios syslog process then there is a high chance that the userspace tunnel will be deadlocked or get into circular waiting lock situation.
To Reproduce
Steps to reproduce the behavior:
Start a userspace tunnel with ios tunnel start --userspace within a console/terminal
Run a script like the below on Windows Powershell (a Linux script can be also used to reproduce)
With some debugging I observe that the connection is getting closed after the one of the io.Close in ioCopyWithErr then the second io.Copy is not aware the one part of the connection is closed and waiting on its _, err := io.Copy(w, r)
Because it doesn't reach to send to unbuffered channel errCh <- err
in this second ioCopyWithErr.
Because the error channel used is unbuffered channel so it is blocking until receiver in proxyConns
return errors.Join(<-err1, <-err2)
is ready and the sender in ioCopyWithErr errCh <- err
should also be ready with unbuffered channels.
Because of the second io.Close stuck due to connection closed on one part. proxyConns wait to receive from second error channel indefinitely.
Describe the bug
When there is high throughput like running a loop to launch/kill app and at the same time getting syslog with another ios syslog process then there is a high chance that the userspace tunnel will be deadlocked or get into circular waiting lock situation.
To Reproduce
Steps to reproduce the behavior:
ios syslog > syslog.txt
The script running in the loop hangs and the tunnel also stalls or totally hangs.
As it is a race condition issue, you may need to stop syslog with Ctrl+C and start again perhaps a few times.
There are some other ways to reproduce which can be provided upon a request.
Expected behavior
Tunnel should continue working and the script loop along with syslog shouldn't be stalled.
Desktop (please complete the following information):
Smartphone (please complete the following information):
Additional context
I narrowed down the problem to the functions :
With some debugging I observe that the connection is getting closed after the one of the io.Close in ioCopyWithErr then the second io.Copy is not aware the one part of the connection is closed and waiting on its
_, err := io.Copy(w, r)
Because it doesn't reach to send to unbuffered channel
errCh <- err
in this second ioCopyWithErr.
Because the error channel used is unbuffered channel so it is blocking until receiver in proxyConns
return errors.Join(<-err1, <-err2)
is ready and the sender in ioCopyWithErr
errCh <- err
should also be ready with unbuffered channels.
Because of the second io.Close stuck due to connection closed on one part. proxyConns wait to receive from second error channel indefinitely.
I worked on PR #503 to propose the fix.
The text was updated successfully, but these errors were encountered: