-
Notifications
You must be signed in to change notification settings - Fork 55
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
console_linux: Fix race: lock Cond before Signal. #27
Conversation
It looks, like your travis install/config has some problems. |
Thanks, looking into the travis issue |
@gerasiov could you rebase this on master? We merge a travis fix for the failing CI. |
Possible race: Thread1: Thread2: line 178: Read() -> EAGAIN ... <reschedule> line 110: EpollWait() ... line 124: signalRead() ... ... line 191: Wait() ... line 110: EpollWait() Thread2 (epoll) sends signalRead() (via sync.Cond) but Thread1 is not waiting yet. Then it starts to wait, but no more signals will arrive (because Thread2 is sleeping in EpollWait() on edge-triggered epoll. To prevent this race one should held Lock when sending signalRead(). The same situation goes with Write loop. Bug was reported to docker: docker/for-linux#353 Signed-off-by: Alexander Gerasiov <[email protected]>
LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ec.readc.Signal() | ||
ec.readc.L.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit.. maybe use defer for the Unlock() calls to mirror existing code pattern.
Is there a way to track when this would make it into a Docker release? |
@djmitche it looks like 18.06 has the fix: moby/moby#35865 (comment) |
Signed-off-by: Petros Angelatos <[email protected]> Connects-To: moby/moby#35865 Connects-To: containerd/console#27
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
relevant changes: - containerd/console#27 console_linux: Fix race: lock Cond before Signal Signed-off-by: Sebastiaan van Stijn <[email protected]>
Possible race:
Thread2 (epoll) sends signalRead() (via sync.Cond) but Thread1 is not waiting
yet. Then is start to wait, but no more signals will arrive (because Thread2
is sleeping in EpollWait() on edge-triggered epoll.
To prevent this race one should held Lock when sending signalRead().
The same situation goes with Write loop.
Bug was reported to docker: docker/for-linux#353
Signed-off-by: Alexander Gerasiov [email protected]