http: fix http server connection list when close#43949
Merged
nodejs-github-bot merged 1 commit intonodejs:mainfrom Jul 24, 2022
Merged
http: fix http server connection list when close#43949nodejs-github-bot merged 1 commit intonodejs:mainfrom
nodejs-github-bot merged 1 commit intonodejs:mainfrom
Conversation
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.
Refs: Failed CI
Refs: Failed CI
Refs: #43638 (comment)
When the socket close, the related parser should be removed out of the server connection list.
When the socket close, the related parser will be cleared(
_http_server.js:socketOnClose -> freeParser), the related code offreeParseris as follows.cleanParser(parser)make thesocket.parseris null, and ifparsers.free(parser)is true anything is ok because it will remove the parser out ofserver.connectionList. But if it is false it will trigger bugs.server.closein the callback of close event, theserver.closewill callcloseIdleConnectionsto close all idle sockets, the code is as follows.connections[i]is a parser object, andparser.socketisnullwhich make the bug(Cannot read properties of null (reading '_httpMessage')).it will make the process crashed because when
closeParserInstanceinsetImmediate(closeParserInstance, parser);is called, it will delete the C++ parser object. Then Node.js will call the second callback(() => { server.close(); }) ofsetImmediate,server.close()will callthis[kConnections].idle()which will access C++ layer to get the parser list, but the parser is delete so make the process crashed. The codedump is as follows.cc @ShogunPanda
make -j4 test(UNIX), orvcbuild test(Windows) passes