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

PR #908 change in _get_interrupt_pair may cause a deadlock #917

Closed
vitaly-krugl opened this issue Jan 11, 2018 · 0 comments
Closed

PR #908 change in _get_interrupt_pair may cause a deadlock #917

vitaly-krugl opened this issue Jan 11, 2018 · 0 comments
Assignees
Milestone

Comments

@vitaly-krugl
Copy link
Member

vitaly-krugl commented Jan 11, 2018

The original code returned a non-blocking socket pair, but the pair is blocking after PR #908. See https://github.com/pika/pika/pull/908/files#r160844142.

The change from non-blocking to blocking can lead to a deadlock. The implementation was designed for non-blocking model - see

if err.errno != errno.EWOULDBLOCK:
and
if err.errno != errno.EAGAIN:
.

A simple/pathological case that would reproduce the deadlock is calling stop enough times from code executing within the event loop itself to fill the socket's transmit buffer.

A more complex - albeit still possibly pathological - case is where a background thread or many background threads call stop, while the event loop code is blocked waiting for something from the thread that happens to make the stop call that would exceed the _w_interrupt socket's transmit buffer.

Is there any reason for removing the logic that made both sockets non-blocking? See https://github.com/pika/pika/pull/908/files#diff-69e7c8c211c62cdb127e8ab3324ce7c6L649

@lukebakken lukebakken added this to the 0.11.3 milestone Jan 11, 2018
@lukebakken lukebakken self-assigned this Jan 11, 2018
@lukebakken lukebakken modified the milestones: 0.11.3, 0.12.0 Jan 11, 2018
gbartl pushed a commit to gbartl/pika that referenced this issue Jan 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants