Skip to content

fix: Preserve inner state when auto-sense client gets unknown version#63

Closed
algesten wants to merge 2 commits intomainfrom
fix-client-pending-panic
Closed

fix: Preserve inner state when auto-sense client gets unknown version#63
algesten wants to merge 2 commits intomainfrom
fix-client-pending-panic

Conversation

@algesten
Copy link
Copy Markdown
Owner

Summary

  • Move the DetectedVersion::Unknown check before self.inner.take() so that returning an error does not leave inner as None
  • Previously, poll_output() and handle_timeout() would panic with unwrap() on None after handle_packet() encountered an unrecognized server response in auto-sense client mode
  • Add regression test that verifies poll_output and handle_timeout work after the error

Fixes #62

Test plan

  • New test test_auto_client_unknown_version_no_panic — feeds garbage to an auto-sense client, asserts UnexpectedMessage error, then calls handle_timeout and poll_output without panic
  • Full test suite passes (90 tests + 8 doc-tests)

algesten and others added 2 commits February 28, 2026 15:04
Move the DetectedVersion::Unknown check before self.inner.take() so
that returning an error does not leave inner as None. Previously,
poll_output() and handle_timeout() would panic after handle_packet()
encountered an unrecognized server response in auto-sense client mode.

Fixes #62
When ClientPending transitions to Client12/Client13, the engine
timeouts remain Unarmed because new_from_hybrid does not call
handle_timeout. This causes poll_timeout to hit unreachable!().

Also wrap all fallible calls after inner.take() in if-let-Err
patterns to restore self.inner on error, preventing it from being
left as None.
Comment thread src/lib.rs
self.inner = Some(Inner::Server13(server));
return Err(e);
}
self.inner = Some(Inner::Server13(server));
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Looks like the self.inner assignment is undconditional and should happen before if-let?

@algesten algesten closed this Feb 28, 2026
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.

Client dtls auto panic

2 participants