The Wayback Machine - http://web.archive.org/web/20220321175824/https://github.com/nodejs/node/pull/41502
Skip to content
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

http2: fix memory leak when nghttp2 hd threshold is reached #41502

Merged

Conversation

RafaelGSS
Copy link
Member

@RafaelGSS RafaelGSS commented Jan 13, 2022

Address: #35233

nghttp2 contains a header limit as you can see here https://github.com/nghttp2/nghttp2/blob/20079b4c2f688385ba9ecf723f958d0448894879/lib/nghttp2_hd.h#L45 and when this limit is reached, the nghttp2 stops the pipelining with https://github.com/nghttp2/nghttp2/blob/master/lib/nghttp2_hd.c#L1658.

However, due to the fact of headers were processed before the error is thrown, the session still holds the memory reference for those headers and in this situation, it's never free causing the memory leak.

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 13, 2022

Review requested:

Copy link
Member

@mcollina mcollina left a comment

lgtm

@nodejs-github-bot

This comment has been hidden.

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 14, 2022

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 17, 2022

Qard
Qard approved these changes Jan 18, 2022
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 18, 2022

@RafaelGSS RafaelGSS force-pushed the fix/http2-memory-leak-nghttp2 branch from dc64638 to e13dff6 Compare Jan 19, 2022
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 19, 2022

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 20, 2022

@RafaelGSS
Copy link
Member Author

@RafaelGSS RafaelGSS commented Jan 20, 2022

The ARM build produces a slighty different output. Instead of closing the connection on nghttp2 error, it propagates a frameError with NGHTTP2_HEADER_COMP error. I'll look at this at environment with more calm.

@mcollina
Copy link
Member

@mcollina mcollina commented Jan 20, 2022

The ARM build produces a slighty different output. Instead of closing the connection on nghttp2 error, it propagates a frameError with NGHTTP2_HEADER_COMP error. I'll look at this at environment with more calm.

It might well be a difference that we would have to deal with. Maybe add an if depending on the environment?

@RafaelGSS
Copy link
Member Author

@RafaelGSS RafaelGSS commented Jan 21, 2022

@nodejs/build Looks like the nghttp2 behaves slightly different in x86 architectures (Windows and ARM). However, I do not have a machine with these architectures to debug it further. Could somebody help me?

By the way, I have tried with Windows 10 x64 and Ubuntu 20.04 x64, and works fine.

@Trott
Copy link
Member

@Trott Trott commented Jan 21, 2022

@nodejs/build Looks like the nghttp2 behaves slightly different in x86 architectures (Windows and ARM). However, I do not have a machine with these architectures to debug it further. Could somebody help me?

By the way, I have tried with Windows 10 x64 and Ubuntu 20.04 x64, and works fine.

If all else fails, there is a process to get temporary access to a machine: https://github.com/nodejs/build/blob/09308290d8401e15fcd3f7f5c6610a6ea13df75a/GOVERNANCE.md#temporary-access

You can search for open/closed issues with "temporary access" in the subject/title in the https://github.com/nodejs/build to see examples of requests.

@sxa
Copy link
Member

@sxa sxa commented Jan 22, 2022

nghttp2 behaves slightly different in x86 architectures (Windows and ARM).

I'm slightly confused as to what you mean there. Is the failing difference happening on more than just ARM? It sounds like you have a pass on Windows/x86 at least.

Looking at https://ci.nodejs.org/job/node-test-commit-arm/40343/ it looks like it's not failing on 64-bit ARM builds (aarch64/arm64) and is only occurring on 32-bit arm (armv7l). It's also worth noting that the machine it's running on in Matteo's log referenced above is a 32-bit docker container running on a 64-bit OS+kernel, although it's also failing on the "real" 32-bit OSs at https://ci.nodejs.org/job/node-test-binary-arm-12+/14026/

I'll try running a build+tests on one of my personal 32-bit ARM32 hosts and see how it goes ...

@RafaelGSS
Copy link
Member Author

@RafaelGSS RafaelGSS commented Jan 22, 2022

I'm slightly confused as to what you mean there. Is the failing difference happening on more than just ARM? It sounds like you have a pass on Windows/x86 at least.

I may be wrong, but looks like it is failing in Windows 2012 R2 x86 as well https://ci.nodejs.org/job/node-test-binary-windows-js-suites/13225/RUN_SUBSET=2,nodes=win2012r2-COMPILED_BY-vs2019-x86/testReport/junit/(root)/test/parallel_test_http2_options_max_headers_exceeds_nghttp2/

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 25, 2022

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 25, 2022

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 26, 2022

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 26, 2022

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 27, 2022

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 27, 2022

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 28, 2022

Commit Queue failed
- Loading data for nodejs/node/pull/41502
✔  Done loading data for nodejs/node/pull/41502
----------------------------------- PR info ------------------------------------
Title      http2: fix memory leak when nghttp2 hd threshold is reached (#41502)
Author     Rafael Silva  (@RafaelGSS)
Branch     RafaelGSS:fix/http2-memory-leak-nghttp2 -> nodejs:master
Labels     c++, http2, needs-ci
Commits    1
 - http2: fix memory leak on nghttp2 hd threshold
Committers 1
 - RafaelGSS 
PR-URL: https://github.com/nodejs/node/pull/41502
Reviewed-By: Matteo Collina 
Reviewed-By: Stephen Belanger 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/41502
Reviewed-By: Matteo Collina 
Reviewed-By: Stephen Belanger 
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last review:
   ⚠  - http2: fix memory leak on nghttp2 hd threshold
   ℹ  This PR was created on Thu, 13 Jan 2022 19:41:46 GMT
   ✔  Approvals: 2
   ✔  - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/41502#pullrequestreview-852212678
   ✔  - Stephen Belanger (@Qard): https://github.com/nodejs/node/pull/41502#pullrequestreview-855912162
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2022-01-27T17:14:01Z: https://ci.nodejs.org/job/node-test-pull-request/42196/
- Querying data for job/node-test-pull-request/42196/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/1762462520

Copy link
Member

@mcollina mcollina left a comment

lgtm

@nodejs-github-bot nodejs-github-bot merged commit f98a785 into nodejs:master Jan 28, 2022
55 checks passed
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Jan 28, 2022

Landed in f98a785

Linkgoron added a commit to Linkgoron/node that referenced this issue Jan 31, 2022
PR-URL: nodejs#41502
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
ruyadorno added a commit that referenced this issue Feb 8, 2022
PR-URL: #41502
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
danielleadams added a commit that referenced this issue Mar 2, 2022
PR-URL: #41502
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
danielleadams added a commit that referenced this issue Mar 3, 2022
PR-URL: #41502
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
danielleadams added a commit that referenced this issue Mar 14, 2022
PR-URL: #41502
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants