Skip to content

Commit a534175

Browse files
santigimenodanielleadams
authored andcommitted
http2: fix crash on Http2Stream::diagnostic_name()
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>
1 parent 0cbd2c6 commit a534175

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/node_http2.cc

+5-2
Original file line numberDiff line numberDiff line change
@@ -2060,9 +2060,12 @@ void Http2Stream::MemoryInfo(MemoryTracker* tracker) const {
20602060
}
20612061

20622062
std::string Http2Stream::diagnostic_name() const {
2063+
const Http2Session* sess = session();
2064+
const std::string sname =
2065+
sess ? sess->diagnostic_name() : "session already destroyed";
20632066
return "HttpStream " + std::to_string(id()) + " (" +
2064-
std::to_string(static_cast<int64_t>(get_async_id())) + ") [" +
2065-
session()->diagnostic_name() + "]";
2067+
std::to_string(static_cast<int64_t>(get_async_id())) + ") [" + sname +
2068+
"]";
20662069
}
20672070

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

0 commit comments

Comments
 (0)