镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Crash when mode is to big in fs.createWriteStream #37430

Description

@coderaiser
  • Version: v14.15.4, v15.9.0
  • Platform: Ubuntu, Mac OS
  • Subsystem: fs

What steps will reproduce the bug?

Node.js crashes on such code:

const {createWriteStream} = require('fs');

createWriteStream('./1.txt', {
    mode: 2176057344,
});

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

Always

What is the expected behavior?

Expected to throw, like it happen when mode is 111111111111111:

node:internal/validators:102
      throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value);
      ^

RangeError [ERR_OUT_OF_RANGE]: The value of "mode" is out of range. It must be >= 0 && <= 4294967295. Received 111_111_111_111_111
    at parseFileMode (node:internal/validators:68:5)
    at Object.open (node:fs:473:12)
    at WriteStream._construct (node:internal/fs/streams:64:17)
    at constructNT (node:internal/streams/destroy:288:25)
    at processTicksAndRejections (node:internal/process/task_queues:80:21) {
  code: 'ERR_OUT_OF_RANGE'
}

What do you see instead?

I see a crash:

node[70201]: ../src/node_file.cc:1715:void node::fs::Open(const FunctionCallbackInfo<v8::Value> &): Assertion `args[2]->IsInt32()' failed.
 1: 0x1012e4da5 node::Abort() (.cold.1) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 2: 0x1000a6239 node::Abort() [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 3: 0x1000a60a1 node::Assert(node::AssertionInfo const&) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 4: 0x1000ae8d2 node::fs::Open(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 5: 0x10025a4e8 v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 6: 0x100259a7c v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 7: 0x1002591a2 v8::internal::Builtin_Impl_HandleApiCall(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
 8: 0x100a7a359 Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit [/Users/coderaiser/.nvm/versions/node/v14.15.4/bin/node]
Abort trap: 6

Additional information

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.fsIssues and PRs related to file-system APIs and the fs module.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions