Skip to content

Commit

Permalink
http2: fix crash on Http2Stream::diagnostic_name()
Browse files Browse the repository at this point in the history
It can happen that the Http2Stream::session_ has already been deleted
when the Http2Stream destructor is called, causing `diagnostic_name()`
to crash. Observed when running some http2 tests on Windows with the
debug logs activated.

PR-URL: #45123
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
  • Loading branch information
santigimeno authored and danielleadams committed Jan 3, 2023
1 parent 0cbd2c6 commit a534175
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/node_http2.cc
Expand Up @@ -2060,9 +2060,12 @@ void Http2Stream::MemoryInfo(MemoryTracker* tracker) const {
}

std::string Http2Stream::diagnostic_name() const {
const Http2Session* sess = session();
const std::string sname =
sess ? sess->diagnostic_name() : "session already destroyed";
return "HttpStream " + std::to_string(id()) + " (" +
std::to_string(static_cast<int64_t>(get_async_id())) + ") [" +
session()->diagnostic_name() + "]";
std::to_string(static_cast<int64_t>(get_async_id())) + ") [" + sname +
"]";
}

// Notify the Http2Stream that a new block of HEADERS is being processed.
Expand Down

0 comments on commit a534175

Please sign in to comment.