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

fs.chown crashes when uid is -1 #58826

Description

@kt3k

Version

24.3

Platform

Darwin kt3k-mac-2.local 23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:21 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T8103 arm64

Subsystem

fs

What steps will reproduce the bug?

Run

import fs from "node:fs";
fs.chown("foo", -1, 501, console.log);

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

always

What is the expected behavior? Why is that the expected behavior?

does not crash

What do you see instead?

crashes

Additional information

This didn't happen with Node 24.2

Activity

  1. bnoordhuis commented on Jun 25, 2025

    @bnoordhuis
    Member

    Define "crashes", please.

  2. kt3k commented on Jun 25, 2025

    @kt3k
    ContributorAuthor

    I meant it prints the error on C++ side, which can't be handled in JavaScript, and exits the program immediately.

  3. kt3k commented on Jun 25, 2025

    @kt3k
    ContributorAuthor

    This change seems related #57931

    It asserts CHECK(value->IsUint32()) for uid and gid.

  4. himself65 commented on Jun 25, 2025

    @himself65
    Member

    I can see the failure here on 24.3.0

    node
    Welcome to Node.js v24.3.0.
    Type ".help" for more information.
    > const fs = require('fs')
    undefined
    > fs.chown("a", -1, 501, console.log);
    
      #  node[22956]: T node::FromV8Value(v8::Local<v8::Value>) [T = unsigned int] at ../src/util-inl.h:642
      #  Assertion failed: value->IsUint32()
    
    ----- Native stack trace -----
    
     1: 0x1047ef040 node::Assert(node::AssertionInfo const&) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
     2: 0x1068939fc node::fs::Chown(v8::FunctionCallbackInfo<v8::Value> const&) (.cold.7) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
     3: 0x10480b708 node::fs::Chown(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
     4: 0x10564a818 Builtins_CallApiCallbackGeneric [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
     5: 0x105648bec Builtins_InterpreterEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
     6: 0x105648bec Builtins_InterpreterEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
     7: 0x1056468cc Builtins_JSEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
     8: 0x105646570 Builtins_JSEntry [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
     9: 0x104b7090c v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    10: 0x104b70ed0 v8::internal::Execution::CallScript(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::JSFunction>, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::DirectHandle<v8::internal::Object>) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    11: 0x1049d4124 v8::Script::Run(v8::Local<v8::Context>, v8::Local<v8::Data>) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    12: 0x1047dbfe8 node::contextify::ContextifyScript::EvalMachine(v8::Local<v8::Context>, node::Environment*, long long, bool, bool, bool, v8::MicrotaskQueue*, v8::FunctionCallbackInfo<v8::Value> const&) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    13: 0x1047db934 node::contextify::ContextifyScript::RunInContext(v8::FunctionCallbackInfo<v8::Value> const&) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    14: 0x10564a818 Builtins_CallApiCallbackGeneric [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    15: 0x105648bec Builtins_InterpreterEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    16: 0x105648bec Builtins_InterpreterEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    17: 0x105648bec Builtins_InterpreterEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    18: 0x105648bec Builtins_InterpreterEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    19: 0x105648bec Builtins_InterpreterEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    20: 0x1400073d8 
    21: 0x1400389d0 
    22: 0x105648bec Builtins_InterpreterEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    23: 0x105648bec Builtins_InterpreterEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    24: 0x140029614 
    25: 0x140036414 
    26: 0x14002e29c 
    27: 0x140007284 
    28: 0x1400389d0 
    29: 0x140031510 
    30: 0x105689ce8 Builtins_GeneratorPrototypeNext [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    31: 0x14001b8e4 
    32: 0x140007284 
    33: 0x1400389d0 
    34: 0x140022954 
    35: 0x140023b58 
    36: 0x140023e8c 
    37: 0x1400353c4 
    38: 0x140024354 
    39: 0x1056468cc Builtins_JSEntryTrampoline [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    40: 0x105646570 Builtins_JSEntry [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    41: 0x104b7090c v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    42: 0x104b70270 v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::DirectHandle<v8::internal::Object>, v8::internal::DirectHandle<v8::internal::Object>, v8::base::Vector<v8::internal::DirectHandle<v8::internal::Object> const>) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    43: 0x1049e5c9c v8::Function::Call(v8::Isolate*, v8::Local<v8::Context>, v8::Local<v8::Value>, int, v8::Local<v8::Value>*) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    44: 0x1046e9244 node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context, v8::Local<v8::Value>) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    45: 0x1046ff768 node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    46: 0x104910edc node::StreamBase::CallJSOnreadMethod(long, v8::Local<v8::ArrayBuffer>, unsigned long, node::StreamBase::StreamBaseJSChecks) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    47: 0x104912678 node::EmitToJSStreamListener::OnStreamRead(long, uv_buf_t const&) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    48: 0x104916ad8 node::LibuvStreamWrap::OnUvRead(long, uv_buf_t const*) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    49: 0x104917220 node::LibuvStreamWrap::ReadStart()::$_1::__invoke(uv_stream_s*, long, uv_buf_t const*) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    50: 0x105630b84 uv__stream_io [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    51: 0x1056391ac uv__io_poll [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    52: 0x10562555c uv_run [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    53: 0x1046e9a98 node::SpinEventLoopInternal(node::Environment*) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    54: 0x10483b704 node::NodeMainInstance::Run() [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    55: 0x1047a9474 node::Start(int, char**) [/Users/himself65/.local/share/fnm/node-versions/v24.3.0/installation/bin/node]
    56: 0x196d22b98 start [/usr/lib/dyld]
    
    ----- JavaScript stack trace -----
    
    1: chown (node:fs:2137:11)
    2: REPL2:1:4
    3: runInThisContext (node:vm:137:12)
    4: defaultEval (node:repl:599:22)
    5: bound (node:domain:433:15)
    6: runBound (node:domain:444:12)
    7: onLine (node:repl:930:10)
    8: emit (node:events:519:35)
    9: emit (node:domain:489:12)
    10: [_onLine] (node:internal/readline/interface:469:12)
    
    
    [1]    22956 abort      node
  5. added
    confirmed-bugIssues and PRs for confirmed bugs.
    fsIssues and PRs related to file-system APIs and the fs module.
    on Jun 25, 2025
  6. himself65 commented on Jun 25, 2025

    @himself65
    Member

    im working on this

  7. added theissue type on Jun 29, 2025
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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions