-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak with http2 write() #18169
Comments
Entirely possible. Will investigate. ping /cc @addaleax |
Evaluating test-http2-zero-length-write.js is not revealing any leaks when using the lower level API. @dolanmiu ... can I ask you to please put together a more complete test case that demonstrates the issue consistently that I can try. Thank you. |
How are you calling |
Here, I have created a simplified script to re-create the issue: save it as a const http2 = require("http2");
const client = http2.connect(`https://www.google.com`);
const req = client.request({
":method": "POST",
":path": `/v2/events`,
authorization: `Bearer test-here`,
"content-type": "multipart/form-data; boundary=dench-gang",
});
req.on("response", (headers, flags) => {
for (const name in headers) {
console.log(`${name}: ${headers[name]}`);
}
});
req.write("");
req.end(); |
@addaleax no loop from what I can see, unless I am missing something |
I think I've found the key. I'll work on it. |
If we do `req.write("")` (an empty string) on Http2Stream, the gather logic will be messed up: ``` while ((src_length = nghttp2_session_mem_send(session_, &src)) > 0) { printf("write\n"); DEBUG_HTTP2SESSION2(this, "nghttp2 has %d bytes to send", src_length); CopyDataIntoOutgoing(src, src_length); } ``` The logic above is in function `Http2Session::SendPendingData` under src/node_http2.cc. This `while` will be endless when an empty string is inside because `src_length` will always be 9. And then the main event loop thread will be blocked and the memory used will be larger and larger. This pull request is to ignore empty string or buffer in `_write()` and `_writev()` of Http2Stream. Fixes: nodejs#18169 Refs: https://github.com/nodejs/node/blob/v9.5.0/src/node_http2.cc#L1481-L1484 Refs: https://github.com/nodejs/node/blob/v9.5.0/lib/_http_outgoing.js#L659-L661
PR-URL: nodejs#18924 Fixes: nodejs#18169 Refs: nodejs#18673 Refs: https://github.com/nodejs/node/blob/v9.5.0/src/node_http2.cc#L1481-L1484 Refs: https://github.com/nodejs/node/blob/v9.5.0/lib/_http_outgoing.js#L659-L661 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: nodejs#18924 Fixes: nodejs#18169 Refs: nodejs#18673 Refs: https://github.com/nodejs/node/blob/v9.5.0/src/node_http2.cc#L1481-L1484 Refs: https://github.com/nodejs/node/blob/v9.5.0/lib/_http_outgoing.js#L659-L661 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Backport-PR-URL: #20456 PR-URL: #18924 Fixes: #18169 Refs: #18673 Refs: https://github.com/nodejs/node/blob/v9.5.0/src/node_http2.cc#L1481-L1484 Refs: https://github.com/nodejs/node/blob/v9.5.0/lib/_http_outgoing.js#L659-L661 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
PR-URL: nodejs#18924 Fixes: nodejs#18169 Refs: nodejs#18673 Refs: https://github.com/nodejs/node/blob/v9.5.0/src/node_http2.cc#L1481-L1484 Refs: https://github.com/nodejs/node/blob/v9.5.0/lib/_http_outgoing.js#L659-L661 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Backport-PR-URL: #20456 PR-URL: #18924 Fixes: #18169 Refs: #18673 Refs: https://github.com/nodejs/node/blob/v9.5.0/src/node_http2.cc#L1481-L1484 Refs: https://github.com/nodejs/node/blob/v9.5.0/lib/_http_outgoing.js#L659-L661 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Backport-PR-URL: #20456 PR-URL: #18924 Fixes: #18169 Refs: #18673 Refs: https://github.com/nodejs/node/blob/v9.5.0/src/node_http2.cc#L1481-L1484 Refs: https://github.com/nodejs/node/blob/v9.5.0/lib/_http_outgoing.js#L659-L661 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Khaidi Chu <i@2333.moe> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
http2
If you use
req.write("")
inhttp2
, with an empty string, the memory gets higher and higher without end. Memory leak?Note: Re-creation script is a few posts down this one
The text was updated successfully, but these errors were encountered: