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

"fs.writeSync" results in an abort #38168

Closed
zyscoder opened this issue Apr 9, 2021 · 2 comments · Fixed by #38183
Closed

"fs.writeSync" results in an abort #38168

zyscoder opened this issue Apr 9, 2021 · 2 comments · Fixed by #38183
Labels
confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system.

Comments

@zyscoder
Copy link

zyscoder commented Apr 9, 2021

What steps will reproduce the bug?

Setup a node instance,

» node

and run the following javascript code.

fs.writeSync(1,'str',0,'hex');

Then the node instance occurs an abort.

How often does it reproduce? Is there a required condition?

This abort can always be triggered following the steps above.

What is the expected behavior?

If any error occurs, an exception or other similar error-reporting stuff should be thrown. There is no reason to abort the whole node process.

What do you see instead?

» node
Welcome to Node.js v14.15.1.
Type ".help" for more information.
> fs.writeSync(1,'str',0,'hex');
node[10818]: ../src/string_bytes.cc:433:static v8::Maybe<long unsigned int> node::StringBytes::StorageSize(v8::Isolate*, v8::Local<v8::Value>, node::encoding): Assertion `str->Length() % 2 == 0 && "invalid hex string length"' failed.
 1: 0xa03530 node::Abort() [node]
 2: 0xa035ae  [node]
 3: 0xadb6ba node::StringBytes::StorageSize(v8::Isolate*, v8::Local<v8::Value>, node::encoding) [node]
 4: 0xa110fe  [node]
 5: 0xbe369b  [node]
 6: 0xbe4c46  [node]
 7: 0xbe52c6 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
 8: 0x13ff259  [node]
[1]    10818 abort (core dumped)  node                                                                                                                                                                                                            

Additional information

@Ayase-252 Ayase-252 added the fs Issues and PRs related to the fs subsystem / file system. label Apr 9, 2021
@aduh95
Copy link
Contributor

aduh95 commented Apr 9, 2021

Duplicate of #37874. I read the issue too fast, this not the same issue.

@aduh95 aduh95 closed this as completed Apr 9, 2021
@aduh95 aduh95 added the duplicate Issues and PRs that are duplicates of other issues or PRs. label Apr 9, 2021
cjihrig added a commit to cjihrig/node that referenced this issue Apr 10, 2021
The binding layer performs some validation of the encoding and
data passed to WriteString(). This commit adds similar validation
to the JS layer for better error handling.

Refs: nodejs#38168
@BridgeAR
Copy link
Member

Reopened as the mentioned issue does not seem to be a duplicate to me.

@BridgeAR BridgeAR reopened this Apr 10, 2021
@BridgeAR BridgeAR added confirmed-bug Issues with confirmed bugs. and removed duplicate Issues and PRs that are duplicates of other issues or PRs. labels Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants