Fix crash in HttpSM::tunnel_handler on unhandled VC events#12959
Merged
bryancall merged 1 commit intoapache:masterfrom Mar 12, 2026
Merged
Fix crash in HttpSM::tunnel_handler on unhandled VC events#12959bryancall merged 1 commit intoapache:masterfrom
bryancall merged 1 commit intoapache:masterfrom
Conversation
tunnel_handler is set as the VC read/write handler for the server connection after response header parsing, but it only asserts for HTTP_TUNNEL_EVENT_DONE and VC_EVENT_INACTIVITY_TIMEOUT. If a VC_EVENT_ACTIVE_TIMEOUT, VC_EVENT_ERROR, or VC_EVENT_EOS arrives on the server connection, the assertion fires and aborts the process. Widen the assertion to accept these events. The handler already sets terminate_sm = true for all events, so the behavior is correct — only the assertion was too narrow. Fixes apache#12958
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an assertion-triggered crash in HttpSM::tunnel_handler by allowing additional VC event types that can legitimately be dispatched to the tunnel handler (notably via HTTP/2 paths), while preserving the existing “terminate the state machine” behavior.
Changes:
- Expands the accepted event list in the
tunnel_handlerassertion to includeVC_EVENT_ACTIVE_TIMEOUT,VC_EVENT_ERROR, andVC_EVENT_EOS.
You can also share your feedback on Copilot code review. Take the survey.
zwoop
approved these changes
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a fatal crash in
HttpSM::tunnel_handlercaused by an overly narrow assertion.The assertion on line 3117 acts as a whitelist of expected events — it passes silently when the event matches, and crashes the process when it doesn't:
ink_assert(event == HTTP_TUNNEL_EVENT_DONE || event == VC_EVENT_INACTIVITY_TIMEOUT);The problem is that
VC_EVENT_ACTIVE_TIMEOUT,VC_EVENT_ERROR, andVC_EVENT_EOSare all legitimate events that can arrive here (particularly via HTTP/2 code paths), but they weren't in the whitelist. When one of these events arrived, the assertion evaluated tofalseand aborted the process.The code immediately after the assertion already handles all events correctly — it sets
terminate_sm = trueand returns. So the behavior was already right; the assertion was just too narrow and killed the process before the correct code could run.The fix adds these three events to the assertion whitelist so they pass through to the existing (correct) termination logic.
Root Cause
This was exposed by #5824 ("Reactivate active timeout enforcement"), which changed the InactivityCop to dispatch specific
VC_EVENT_ACTIVE_TIMEOUTevents instead of the genericEVENT_IMMEDIATEthat was used before. That PR also added active timeout checking to the InactivityCop for the first time — before it,VC_EVENT_ACTIVE_TIMEOUTwas never dispatched from the cop, so handlers liketunnel_handlernever saw it. The assertion was never updated to account for the new event types.Background
Observed as a fatal crash on
controller.trafficserver.org(ATS 10.2.0, ASAN build) through an HTTP/2 code path:Every other VC handler in HttpSM already accepts these events —
tunnel_handlerwas the only one missing them.Fixes #12958
Test plan