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

src: do not pass nullptr to std::string ctor #57354

Conversation

ckerr
Copy link
Contributor

@ckerr ckerr commented Mar 7, 2025

Fixes this error that I hit when working on a Chromium bump today in Electron:

2025-03-07T01:05:01.8637705Z ../../third_party/electron_node/src/debug_utils.cc(257,12): error: null passed to a callee that requires a non-null argument [-Werror,-Wnonnull]
2025-03-07T01:05:01.8638267Z 257 | return nullptr;
2025-03-07T01:05:01.8638481Z | ^~~~~~~
2025-03-07T01:05:01.8638700Z 1 error generated.

This code has been around for awhile in Node.js, so the new build failure is probably an Electron issue, e.g. CI config.

Even so, upstreaming a fix feels worthwhile since building a std::string from nullptris undefined behavior in C++20 and is prohibited as of C++23.

This PR just replaces the return nullptr; with a return {}; in a function that returns a std::string.

CC @codebytere

fixes -Wnonnull warning on some compilers
@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. debugger Issues and PRs related to the debugger subsystem. needs-ci PRs that need a full CI run. labels Mar 7, 2025
Copy link

codecov bot commented Mar 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.21%. Comparing base (117c1ca) to head (c8a3a3d).
Report is 18 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #57354   +/-   ##
=======================================
  Coverage   90.21%   90.21%           
=======================================
  Files         630      630           
  Lines      185304   185304           
  Branches    36261    36266    +5     
=======================================
+ Hits       167178   167179    +1     
- Misses      11082    11084    +2     
+ Partials     7044     7041    -3     
Files with missing lines Coverage Δ
src/debug_utils.cc 60.90% <ø> (ø)

... and 23 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.

@daeyeon daeyeon added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 7, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 7, 2025
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@codebytere codebytere removed the needs-ci PRs that need a full CI run. label Mar 7, 2025
@codebytere codebytere changed the title src: do not pass nullptr to std::string ctor src: do not pass nullptr to std::string ctor Mar 7, 2025
@addaleax addaleax added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Mar 8, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 9, 2025
@nodejs-github-bot nodejs-github-bot merged commit 9a9a45a into nodejs:main Mar 9, 2025
75 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 9a9a45a

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++. debugger Issues and PRs related to the debugger subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants