GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: fix memory leaks and refactor ByteSource by tniessen · Pull Request #43202 · nodejs/node

Conversation

@tniessen

@tniessen tniessen commented May 24, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

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.

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.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss and addaleax reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@nodejs-github-bot

nodejs-github-bot commented May 24, 2022

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/crypto
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels May 24, 2022
@tniessen tniessen added the crypto Issues and PRs related to the crypto subsystem. label May 24, 2022
@tniessen
tniessen force-pushed the src-memory-leaks-and-refactor-bytesource branch 5 times, most recently from 45a1378 to 2b6e52e Compare May 25, 2022 22:00
@tniessen tniessen added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label May 25, 2022
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label May 25, 2022
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
@nodejs-github-bot

nodejs-github-bot commented May 27, 2022

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/44193/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tniessen tniessen added the review wanted PRs that need review. label May 27, 2022
This was referenced May 28, 2022
CI Reliability 2022-05-28 nodejs/reliability#291
Open
CI Reliability 2022-05-29 nodejs/reliability#292
Open
CI Reliability 2022-05-30 nodejs/reliability#293
Open
CI Reliability 2022-05-31 nodejs/reliability#294
Open
CI Reliability 2022-06-01 nodejs/reliability#295
Open
@tniessen

tniessen commented Jun 1, 2022

Copy link
Copy Markdown
Member Author

This has been open for more than a week with no comments... ping @nodejs/crypto.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos

targos commented Jun 2, 2022

Copy link
Copy Markdown
Member

Do we have a team to ping for C++ reviews?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tniessen

tniessen commented Jun 2, 2022 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

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 @nodejs/cpp-reviewers.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tniessen tniessen mentioned this pull request Jun 2, 2022
Create GitHub team for reviewing src (C++) changes nodejs/TSC#1237
Closed
@tniessen

tniessen commented Jun 9, 2022

Copy link
Copy Markdown
Member Author

This has been open for more than two weeks with no comments... ping @nodejs/cpp-reviewers @nodejs/crypto.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

addaleax
addaleax approved these changes Jun 10, 2022
View reviewed changes
Comment thread src/crypto/crypto_util.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

@panva panva added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Jun 10, 2022
RaisinTen
RaisinTen approved these changes Jun 10, 2022
View reviewed changes
@aduh95 aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Jun 12, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Jun 12, 2022
@nodejs-github-bot

nodejs-github-bot commented Jun 12, 2022

Copy link
Copy Markdown
Collaborator
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/.ncu
https://github.com/nodejs/node/actions/runs/2483034882
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Jun 12, 2022
@aduh95
aduh95 merged commit 167ea80 into nodejs:master Jun 12, 2022
@aduh95

aduh95 commented Jun 12, 2022

Copy link
Copy Markdown
Contributor

Landed in 167ea80

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@danielleadams danielleadams mentioned this pull request Jun 13, 2022
v18.4.0 proposal #43385
Merged
@github-actions github-actions Bot mentioned this pull request Jun 13, 2022
CI Reliability 2022-06-13 nodejs/reliability#299
Open
15 tasks
danielleadams pushed a commit that referenced this pull request Jun 13, 2022
@tniessen @danielleadams
src: fix memory leaks and refactor ByteSource
931ecfa
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 <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@github-actions github-actions Bot mentioned this pull request Jun 14, 2022
CI Reliability 2022-06-14 nodejs/reliability#300
Open
16 tasks
@tniessen tniessen mentioned this pull request Jun 18, 2022
crypto: use ByteSource::Builder in To*Copy #43477
Merged
tniessen added a commit to tniessen/node that referenced this pull request Jun 18, 2022
@tniessen
crypto: use ByteSource::Builder in To*Copy
0e6123d
Avoid manual calls to MallocOpenSSL in ArrayBufferOrViewContents and
use the new ByteSource::Builder instead.

Refs: nodejs#43202
nodejs-github-bot pushed a commit that referenced this pull request Jun 25, 2022
@tniessen
crypto: use ByteSource::Builder in To*Copy
42ad967
Avoid manual calls to MallocOpenSSL in ArrayBufferOrViewContents and
use the new ByteSource::Builder instead.

Refs: #43202

PR-URL: #43477
Reviewed-By: Darshan Sen <[email protected]>
targos pushed a commit that referenced this pull request Jul 12, 2022
@tniessen @targos
crypto: use ByteSource::Builder in To*Copy
a43928a
Avoid manual calls to MallocOpenSSL in ArrayBufferOrViewContents and
use the new ByteSource::Builder instead.

Refs: #43202

PR-URL: #43477
Reviewed-By: Darshan Sen <[email protected]>
@targos targos added the backport-requested-v16.x label Jul 21, 2022
@targos

targos commented Jul 21, 2022

Copy link
Copy Markdown
Member

This would need a backport to land on v16.x because std::optional and std::nullopt are not available on that branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

tniessen added a commit to tniessen/node that referenced this pull request Jul 26, 2022
@tniessen
src: remove unnecessary cast in crypto_sig.cc
d9aaf23
ByteSource::Allocated accepts a void pointer now, so we do not need to
cast the argument to a char pointer.

Refs: nodejs#43202
@tniessen tniessen mentioned this pull request Jul 26, 2022
src: remove unnecessary cast in crypto_sig.cc #44001
Merged
nodejs-github-bot pushed a commit that referenced this pull request Jul 27, 2022
@tniessen
src: remove unnecessary cast in crypto_sig.cc
abddacb
ByteSource::Allocated accepts a void pointer now, so we do not need to
cast the argument to a char pointer.

Refs: #43202

PR-URL: #44001
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
danielleadams pushed a commit that referenced this pull request Aug 16, 2022
@tniessen @danielleadams
src: remove unnecessary cast in crypto_sig.cc
2c44730
ByteSource::Allocated accepts a void pointer now, so we do not need to
cast the argument to a char pointer.

Refs: #43202

PR-URL: #44001
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
ruyadorno pushed a commit that referenced this pull request Aug 23, 2022
@tniessen @ruyadorno
src: remove unnecessary cast in crypto_sig.cc
4603977
ByteSource::Allocated accepts a void pointer now, so we do not need to
cast the argument to a char pointer.

Refs: #43202

PR-URL: #44001
Reviewed-By: Filip Skokan <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
Reviewed-By: Feng Yu <[email protected]>
@tniessen tniessen mentioned this pull request Sep 1, 2022
src: use automatic memory mgmt in SecretKeyGen #44479
Merged
@targos targos added dont-land-on-v16.x and removed backport-requested-v16.x labels Sep 16, 2022
@panva panva mentioned this pull request Apr 1, 2023
[v16.x backport] WebCryptoAPI fixes #47336
Closed
@panva panva mentioned this pull request May 31, 2023
Perf regression on crypto.verify nodejs/performance#72
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jasnell jasnell jasnell approved these changes
@addaleax addaleax addaleax approved these changes
@RaisinTen RaisinTen RaisinTen approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. crypto Issues and PRs related to the crypto subsystem. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

8 participants

@tniessen @nodejs-github-bot @targos @aduh95 @jasnell @addaleax @RaisinTen @panva
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.