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

don't block sendQueue.Send() if the runloop already exited. #2656

Merged
merged 1 commit into from
Jul 10, 2020

Conversation

ltucker
Copy link
Contributor

@ltucker ltucker commented Jul 8, 2020

This can lead to a deadlock where session.shutdown() never exits
because it is blocked on a Send() but the sendQueue has exited due to
a write error.

Fixes #2655 but needs consideration for other consequences ...

@marten-seemann marten-seemann self-requested a review July 8, 2020 04:12
Copy link
Member

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks correct to me. One suggestion to improve the test case.
Also, the file seems to be not gofmted correctly (which is why Travis is complaining).

q.Run()
close(done)
}()
q.Close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a PacketConn that errors here, instead of calling close? That more closely mirrors the actual issue that you discovered, as the session only calls Close after calls to Send have returned.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marten-seemann Thanks, I updated this to have the MockConnection trigger an error on Write (how the queue sees that error) -- I'm not sure rigging in an actual PacketConn would add much in this context, but let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, that's actually what I meant. Should have been more precise.

This can lead to a deadlock where session.shutdown() never exits
because it is blocked on a Send() but the sendQueue has exited due to
a write error.
@codecov
Copy link

codecov bot commented Jul 8, 2020

Codecov Report

Merging #2656 into master will increase coverage by 0.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2656      +/-   ##
==========================================
+ Coverage   86.42%   86.46%   +0.05%     
==========================================
  Files         122      122              
  Lines        9761     9765       +4     
==========================================
+ Hits         8435     8443       +8     
+ Misses        990      988       -2     
+ Partials      336      334       -2     
Impacted Files Coverage Δ
send_queue.go 100.00% <100.00%> (+7.69%) ⬆️
internal/ackhandler/sent_packet_handler.go 73.04% <0.00%> (ø)
conn_id_generator.go 90.00% <0.00%> (+0.34%) ⬆️
conn_id_manager.go 94.17% <0.00%> (+1.94%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84bf12b...3c1e597. Read the comment docs.

@marten-seemann marten-seemann merged commit 3dbba00 into quic-go:master Jul 10, 2020
@aschmahmann aschmahmann mentioned this pull request Sep 22, 2020
72 tasks
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

Successfully merging this pull request may close these issues.

Deadlock in session shutdown / sendQueue.Send()
3 participants