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

fix(panic): Stop panicking when handling inbound connection handshakes #6984

Merged
merged 3 commits into from
Jun 19, 2023

Conversation

teor2345
Copy link
Contributor

Motivation

In PR #6969 which just merged yesterday, I introduced a panic bug when handling some inbound handshake errors.

Complex Code or Requirements

The lack of FuturesUnordered types made bugs like this easy to add and tricky to catch.

Solution

  • Fix the panic by handling errors directly on the futures
  • Fix a potential panic on shutdown by logging when tasks are cancelled, rather than panicking unconditionally
  • Prevent panics in other refactors by adding types to errors and FuturesUnordered

Related cleanups:

  • Remove a redundant timeout in outbound handshakes

Review

This could be an urgent fix if it causes panics in other tests or full syncs.

Reviewer Checklist

  • Will the PR name make sense to users?
    • Does it need extra CHANGELOG info? (new features, breaking changes, large changes)
  • Are the PR labels correct?
  • Does the code do what the ticket and PR says?
    • Does it change concurrent code, unsafe code, or consensus rules?
  • How do you know it works? Does it have tests?

@teor2345 teor2345 added C-bug Category: This is a bug P-High 🔥 C-security Category: Security issues I-panic Zebra panics with an internal error message A-network Area: Network protocol updates or fixes I-remote-trigger Remote nodes can make Zebra do something bad labels Jun 16, 2023
@teor2345 teor2345 requested a review from a team as a code owner June 16, 2023 02:00
@teor2345 teor2345 self-assigned this Jun 16, 2023
@teor2345 teor2345 requested review from oxarbitrage and removed request for a team June 16, 2023 02:00
@codecov
Copy link

codecov bot commented Jun 16, 2023

Codecov Report

Merging #6984 (e000024) into main (1e12a58) will decrease coverage by 0.17%.
The diff coverage is 12.50%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6984      +/-   ##
==========================================
- Coverage   77.59%   77.43%   -0.17%     
==========================================
  Files         310      310              
  Lines       41536    41560      +24     
==========================================
- Hits        32231    32182      -49     
- Misses       9305     9378      +73     

Copy link
Contributor

@arya2 arya2 left a comment

Choose a reason for hiding this comment

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

This looks good, I left a few nitpicks.

zebra-network/src/peer_set/initialize.rs Show resolved Hide resolved
zebra-network/src/peer_set/initialize.rs Show resolved Hide resolved
zebra-network/src/peer_set/initialize.rs Show resolved Hide resolved
zebra-network/src/peer_set/initialize.rs Show resolved Hide resolved
mergify bot added a commit that referenced this pull request Jun 18, 2023
@teor2345
Copy link
Contributor Author

@Mergifyio refresh

@mergify
Copy link
Contributor

mergify bot commented Jun 19, 2023

refresh

✅ Pull request refreshed

mergify bot added a commit that referenced this pull request Jun 19, 2023
@mergify mergify bot merged commit 859353b into main Jun 19, 2023
@mergify mergify bot deleted the fix-inbound-panic branch June 19, 2023 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-network Area: Network protocol updates or fixes C-bug Category: This is a bug C-security Category: Security issues I-panic Zebra panics with an internal error message I-remote-trigger Remote nodes can make Zebra do something bad
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants