Skip to content

crypto: avoid copying buffers to UTF-8 strings in crypto.hash() #59067

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Renegade334
Copy link
Contributor

Fixes: #59057

Testing in the wild confirms this to fix the associated downstream issue. Not sure a unit test is feasible.

cc: @nodejs/releasers – given the impact on the ecosystem, this would ideally be a candidate for a patch release.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/crypto

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. labels Jul 14, 2025
@panva panva added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Jul 14, 2025
@panva panva self-requested a review July 14, 2025 09:02
@panva
Copy link
Member

panva commented Jul 14, 2025

This likely will have to wait for after the announced security releases.

@Renegade334 Renegade334 force-pushed the crypto-oneshotdigest-no-stringify-buffers branch from c631a71 to 2a23cf2 Compare July 14, 2025 09:17
Copy link

codecov bot commented Jul 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.06%. Comparing base (049664b) to head (2a23cf2).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #59067   +/-   ##
=======================================
  Coverage   90.06%   90.06%           
=======================================
  Files         645      645           
  Lines      189130   189130           
  Branches    37094    37085    -9     
=======================================
+ Hits       170339   170349   +10     
+ Misses      11511    11507    -4     
+ Partials     7280     7274    -6     
Files with missing lines Coverage Δ
src/crypto/crypto_hash.cc 70.65% <100.00%> (+0.29%) ⬆️

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@panva panva added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jul 14, 2025
Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. On a side note according to #59057 this primarily happens on Linux so is likely attributed to fragmentation in glibc's malloc implementation (#21973), and now it seems to affect sync calls with a lot of buffers as well, which is somewhat concerning as the performance issue can lead to OOM..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. crypto Issues and PRs related to the crypto subsystem. needs-ci PRs that need a full CI run. request-ci Add this label to start a Jenkins CI on a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Node 24.4.0 OOMs with pnpm
5 participants