Skip to content

Commit

Permalink
src: add nullptr check for session in DEBUG macro
Browse files Browse the repository at this point in the history
Currenlty when configuring --debug-http2
/test/parallel/test-http2-getpackedsettings.js will segment fault:

$ out/Debug/node test/parallel/test-http2-getpackedsettings.js
Segmentation fault: 11

This is happening because the settings is created with the Environment in
PackSettings:
Http2Session::Http2Settings settings(env);
This will cause the session to be set to nullptr. When the init
function is later called the expanded DEBUG_HTTP2SESSION macro will
cause the segment fault when the session is dereferenced.

PR-URL: #18815
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
danbev authored and MylesBorins committed Feb 21, 2018
1 parent 4601bfd commit e47fd4c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/node_http2.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,20 @@ void inline debug_vfprintf(const char* format, ...) {
#define DEBUG_HTTP2(...) debug_vfprintf(__VA_ARGS__);
#define DEBUG_HTTP2SESSION(session, message) \
do { \
DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \
session->TypeName(), \
session->get_async_id()); \
if (session != nullptr) { \
DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \
session->TypeName(), \
session->get_async_id()); \
} \
} while (0)
#define DEBUG_HTTP2SESSION2(session, message, ...) \
do { \
DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \
session->TypeName(), \
session->get_async_id(), \
if (session != nullptr) { \
DEBUG_HTTP2("Http2Session %s (%.0lf) " message "\n", \
session->TypeName(), \
session->get_async_id(), \
__VA_ARGS__); \
} \
} while (0)
#define DEBUG_HTTP2STREAM(stream, message) \
do { \
Expand Down

0 comments on commit e47fd4c

Please sign in to comment.