Skip to content

src: fix accessing empty string #57014

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

Merged
merged 1 commit into from
Feb 16, 2025

Conversation

zcbenz
Copy link
Contributor

@zcbenz zcbenz commented Feb 12, 2025

Fix an assertion caused by accessing empty string:

(lldb) run -e "process.loadEnvFile('./test/fixtures/dotenv/eof-without-value.env')"
../../third_party/gn/third_party/libc++/src/include/string_view:411: assertion !empty() failed: string_view::front(): string is empty
(lldb) bt
* thread #1, name = 'MainThread', queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  * frame #0: 0x00007ff81b4dfc52 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007ff81b519f85 libsystem_pthread.dylib`pthread_kill + 262
    frame #2: 0x00007ff81b43ab19 libsystem_c.dylib`abort + 126
    frame #3: 0x0000000101b96cb2 node`std::__Cr::__libcpp_verbose_abort(format=<unavailable>) at verbose_abort.cpp:74:3 [opt]
    frame #4: 0x00000001000fe088 node`node::Dotenv::ParseContent(std::__Cr::basic_string_view<char, std::__Cr::char_traits<char>>) [inlined] std::__Cr::basic_string_view<char, std::__Cr::char_traits<char>>::front(this=<unavailable>) const at string_view:411:12 [opt]
    frame #5: 0x00000001000fe073 node`node::Dotenv::ParseContent(this=0x00007ff7bfefd670, input=<unavailable>) at node_dotenv.cc:159:17 [opt]
    frame #6: 0x00000001000fe4dd node`node::Dotenv::ParsePath(this=0x00007ff7bfefd670, path=<unavailable>) at node_dotenv.cc:296:3 [opt]
    frame #7: 0x000000010018f3e7 node`node::LoadEnvFile(args=0x00007ff7bfefdac8) at node_process_methods.cc:488:18 [opt]

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. labels Feb 12, 2025
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.08%. Comparing base (579fc67) to head (f5ce221).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #57014      +/-   ##
==========================================
- Coverage   89.08%   89.08%   -0.01%     
==========================================
  Files         665      665              
  Lines      193248   193248              
  Branches    37229    37229              
==========================================
- Hits       172157   172151       -6     
- Misses      13806    13821      +15     
+ Partials     7285     7276       -9     
Files with missing lines Coverage Δ
src/node_dotenv.cc 89.61% <100.00%> (-1.64%) ⬇️

... and 25 files with indirect coverage changes

@joyeecheung
Copy link
Member

Can you add a test for this?

@zcbenz
Copy link
Contributor Author

zcbenz commented Feb 12, 2025

Can you add a test for this?

The assertion happened when running tests, when built with newer version of libc++ in GN build. So it is already being tested.

@addaleax addaleax added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 14, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 14, 2025
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@zcbenz zcbenz added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 15, 2025
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 15, 2025
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@jasnell
Copy link
Member

jasnell commented Feb 15, 2025

The windows CI failures appear to be persistent and consistent. Can you please try rebasing this on main before we run again in case there's something not matching up. @nodejs/platform-windows any ideas?

@zcbenz zcbenz force-pushed the empty-string-access branch from f9b5ac9 to f5ce221 Compare February 15, 2025 23:12
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@zcbenz zcbenz added the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 16, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 16, 2025
@nodejs-github-bot nodejs-github-bot merged commit 1d8593e into nodejs:main Feb 16, 2025
53 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 1d8593e

@zcbenz zcbenz deleted the empty-string-access branch February 16, 2025 06:48
targos pushed a commit that referenced this pull request Feb 17, 2025
PR-URL: #57014
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
acidiney pushed a commit to acidiney/node that referenced this pull request Feb 23, 2025
PR-URL: nodejs#57014
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit that referenced this pull request Apr 2, 2025
PR-URL: #57014
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
aduh95 pushed a commit that referenced this pull request Apr 3, 2025
PR-URL: #57014
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 16, 2025
PR-URL: #57014
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
RafaelGSS pushed a commit that referenced this pull request Apr 17, 2025
PR-URL: #57014
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants