Skip to content

[v8.x] src: fix fs.write() externalized string handling - #22731

Closed
addaleax wants to merge 2 commits into
nodejs:v8.x-stagingfrom
addaleax:backport-18216
Closed

[v8.x] src: fix fs.write() externalized string handling#22731
addaleax wants to merge 2 commits into
nodejs:v8.x-stagingfrom
addaleax:backport-18216

Conversation

@addaleax

Copy link
Copy Markdown
Member

Backport #18216

The merge conflicts in node_file.cc were non-trivial, so the changes there deserve to be treated like original content during review.

@nodejs-github-botnodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. v8.x labels Sep 6, 2018
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@addaleax

Copy link
Copy Markdown
MemberAuthor

@MylesBorins

Copy link
Copy Markdown
Contributor

@addaleax should this be included in the 8.12.0 release or is it ok to wait until 8.12.1?

@jasnell

Copy link
Copy Markdown
Member

@addaleax ... would it make sense to add a new test similar to the example case in #22728? Or are the test modifications made here already sufficient?

@addaleax

Copy link
Copy Markdown
MemberAuthor

@MylesBorins It’s hard to tell – I’d be in favour of including it. It’s been in master for long enough to be sure that this doesn’t break anything, I’d say?

@jasnell The tests added here do check the broken code path in string_bytes.cc that #22728 also triggers. How about adding a test similar to that in a separate PR against master?

@jasnell

Copy link
Copy Markdown
Member

How about adding a test similar to that in a separate PR against master?

As long as there is appropriate coverage for this particular piece then it should be fine.

@trivikr

Copy link
Copy Markdown
Member

@MylesBorins

Copy link
Copy Markdown
Contributor

@MylesBorins

Copy link
Copy Markdown
Contributor

This PR seems to be making windows completely fail, any idea what's up?

@richardlau

Copy link
Copy Markdown
Member

It's some sort of compilation failure,

e.g. https://ci.nodejs.org/job/node-compile-windows/21107/label=win-vs2015/console

17:21:30 src\string_bytes.cc(341): error C2589: '(': illegal token on right side of '::' [c:\workspace\node-compile-windows\node_lib.vcxproj]
17:21:30 src\string_bytes.cc(341): error C2059: syntax error: '::' [c:\workspace\node-compile-windows\node_lib.vcxproj]

@richardlau

Copy link
Copy Markdown
Member

src\string_bytes.cc(341):
https://github.com/nodejs/node/blob/ed7b009709bf0156ab2cde9c1ce98c777df72250/src/string_bytes.cc#L341

Among the search results for C2589 is https://stackoverflow.com/questions/5004858/stdmin-gives-error
which suggests we need to define NOMINMAX, which looks like the original PR (#18216) did in 0b1841d.

@BethGriggs

Copy link
Copy Markdown
Member

@addaleax are you able to take a look? Thanks

Build with `-DNOMINMAX` to stop `<windows.h>` from defining macros that
conflict with `std::min()` and `std::max()`.
PR-URL: nodejs#18216
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
* Respect `encoding` argument when the string is externalized.
* Copy the string when the write request can outlive the externalized
string.
This commit removes `StringBytes::GetExternalParts()` because it is
fundamentally broken.
Fixes: nodejs#18146Fixes: nodejs#22728
PR-URL: nodejs#18216
@addaleax

Copy link
Copy Markdown
MemberAuthor

BethGriggs pushed a commit that referenced this pull request Oct 16, 2018
Build with `-DNOMINMAX` to stop `<windows.h>` from defining macros that
conflict with `std::min()` and `std::max()`.
Backport-PR-URL: #22731
PR-URL: #18216
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
PR-URL: #22731
BethGriggs pushed a commit that referenced this pull request Oct 16, 2018
* Respect `encoding` argument when the string is externalized.
* Copy the string when the write request can outlive the externalized
string.
This commit removes `StringBytes::GetExternalParts()` because it is
fundamentally broken.
Fixes: #18146Fixes: #22728
Backport-PR-URL: #22731
PR-URL: #18216
Reviewed-By: James M Snell <jasnell@gmail.com>
@BethGriggs

Copy link
Copy Markdown
Member

Landed in v8.x-staging48f31bd...b67bf38

Sign up for freeto 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++.lib / srcIssues and PRs related to general changes in the lib or src directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants

@addaleax@nodejs-github-bot@MylesBorins@jasnell@trivikr@richardlau@BethGriggs@mihalskiy@bnoordhuis