-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
src: fix memory leaks and refactor ByteSource #43202
src: fix memory leaks and refactor ByteSource #43202
Conversation
Review requested:
|
45a1378
to
2b6e52e
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This has been open for more than a week with no comments... ping @nodejs/crypto. |
Do we have a team to ping for C++ reviews? |
I don't think we do. I suggested this in #43286 (comment) (but I guess a fast-tracked PR wasn't a good place to mention it). Edit: opened nodejs/TSC#1237. Second edit: created |
This has been open for more than two weeks with no comments... ping @nodejs/cpp-reviewers @nodejs/crypto. |
Commit Queue failed- Loading data for nodejs/node/pull/43202 ✔ Done loading data for nodejs/node/pull/43202 ----------------------------------- PR info ------------------------------------ Title src: fix memory leaks and refactor ByteSource (#43202) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch tniessen:src-memory-leaks-and-refactor-bytesource -> nodejs:master Labels crypto, c++, lib / src, author ready, needs-ci Commits 1 - src: fix memory leaks and refactor ByteSource Committers 1 - Tobias Nießen PR-URL: https://github.com/nodejs/node/pull/43202 Reviewed-By: Anna Henningsen Reviewed-By: Darshan Sen Reviewed-By: James M Snell ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/43202 Reviewed-By: Anna Henningsen Reviewed-By: Darshan Sen Reviewed-By: James M Snell -------------------------------------------------------------------------------- ℹ This PR was created on Tue, 24 May 2022 23:01:55 GMT ✔ Approvals: 3 ✔ - Anna Henningsen (@addaleax): https://github.com/nodejs/node/pull/43202#pullrequestreview-1002220635 ✔ - Darshan Sen (@RaisinTen) (TSC): https://github.com/nodejs/node/pull/43202#pullrequestreview-1002898142 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/43202#pullrequestreview-1003512265 ✖ Last GitHub CI failed ℹ Last Full PR CI on 2022-06-12T05:35:56Z: https://ci.nodejs.org/job/node-test-pull-request/44453/ - Querying data for job/node-test-pull-request/44453/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/2483034882 |
Landed in 167ea80 |
Add ByteSource::Builder to replace the common MallocOpenSSL() + ByteSource::Allocated() pattern. Remove ByteSource::reset() that is unused. Remove ByteSource::Resize() to make ByteSource truly immutable (until moved away). Instead, ByteSource::Builder::release() takes an optional size argument that truncates the resulting ByteSource. Fix occurrences of MallocOpenSSL() that do not always free the allocated memory by using the new ByteSource::Builder class instead. Remove ByteSource::get() and replace uses with ByteSource::data(). Remove ReallocOpenSSL() because it likely only saves us a few bytes whenever we use it. PR-URL: nodejs#43202 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Add ByteSource::Builder to replace the common MallocOpenSSL() + ByteSource::Allocated() pattern. Remove ByteSource::reset() that is unused. Remove ByteSource::Resize() to make ByteSource truly immutable (until moved away). Instead, ByteSource::Builder::release() takes an optional size argument that truncates the resulting ByteSource. Fix occurrences of MallocOpenSSL() that do not always free the allocated memory by using the new ByteSource::Builder class instead. Remove ByteSource::get() and replace uses with ByteSource::data(). Remove ReallocOpenSSL() because it likely only saves us a few bytes whenever we use it. PR-URL: #43202 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Add ByteSource::Builder to replace the common MallocOpenSSL() + ByteSource::Allocated() pattern. Remove ByteSource::reset() that is unused. Remove ByteSource::Resize() to make ByteSource truly immutable (until moved away). Instead, ByteSource::Builder::release() takes an optional size argument that truncates the resulting ByteSource. Fix occurrences of MallocOpenSSL() that do not always free the allocated memory by using the new ByteSource::Builder class instead. Remove ByteSource::get() and replace uses with ByteSource::data(). Remove ReallocOpenSSL() because it likely only saves us a few bytes whenever we use it. PR-URL: #43202 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Avoid manual calls to MallocOpenSSL in ArrayBufferOrViewContents and use the new ByteSource::Builder instead. Refs: nodejs#43202
This would need a backport to land on v16.x because |
ByteSource::Allocated accepts a void pointer now, so we do not need to cast the argument to a char pointer. Refs: nodejs#43202
ByteSource::Allocated accepts a void pointer now, so we do not need to cast the argument to a char pointer. Refs: nodejs#43202 PR-URL: nodejs#44001 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Feng Yu <F3n67u@outlook.com>
Add
ByteSource::Builder
to replace the commonMallocOpenSSL()
+ByteSource::Allocated()
pattern.Remove
ByteSource::reset()
that is unused.Remove
ByteSource::Resize()
to makeByteSource
truly immutable (until moved away). Instead,ByteSource::Builder::release()
takes an optional size argument that truncates the resultingByteSource
.Fix occurrences of
MallocOpenSSL()
that do not always free the allocated memory by using the newByteSource::Builder
class instead.Remove
ByteSource::get()
and replace uses withByteSource::data()
.Remove
ReallocOpenSSL()
because it likely only saves us a few bytes whenever we use it.This does save a few dozen lines of code, too. (Much of the diff is just to make the linter happy, which apparently requires changed lines to be formatted, and that increases the diff by about 50 % in this case.)