Skip to content

Segmentation Fault on commands like "bun i" and "bun upgrade" when Carbon Black AV Active on Windows #10056

Closed

Description

@NijoLabs

What version of Bun is running?

1.1.2

What platform is your computer?

Microsoft Windows NT 10.0.19045.0 x64

What steps can reproduce the bug?

Install bun and run command line utilities like "bun install", "bun upgrade" etc in a corporate laptop with Windows, Getting segmentation fault and other errors on the first command run, 2nd time onwards the command seems to work fine.
below is one example. Carbon Black AV dll seems to be the culprit here, Same errors happens with bun install too.

No problems faced with NPM, maybe make bun executable white listed with major AV vendors?

  1. bun upgrade

PS C:\Work\Angular Study\DynamicHeader> bun upgrade
Bun v1.1.2 is out! You're on 1.1.1
Segmentation fault at address 0xdc2d01e010
???:?:?: 0x7ffada7fda29 in ??? (ctiuser.dll)
???:?:?: 0x7ffb2bc0dd62 in ??? (KERNELBASE.dll)
???:?:?: 0x7ffb2de9d38b in ??? (KERNEL32.DLL)
???:?:?: 0x7ff77b568f7d in ??? (bun.exe)
???:?:?: 0x7ff77b56a4b4 in ??? (bun.exe)
???:?:?: 0x7ff77b45bbbe in ??? (bun.exe)
???:?:?: 0x7ff77b58ac0d in ??? (bun.exe)
???:?:?: 0x7ff77b58c406 in ??? (bun.exe)
???:?:?: 0x7ff77b5990e7 in ??? (bun.exe)
???:?:?: 0x7ff77b2c1603 in ??? (bun.exe)
???:?:?: 0x7ff77de43ec3 in ??? (bun.exe)
???:?:?: 0x7ffb2de97343 in ??? (KERNEL32.DLL)
???:?:?: 0x7ffb2e1a26b0 in ??? (ntdll.dll)
PS C:\Work\Angular Study\DynamicHeader> bun upgrade
Congrats! You're already on the latest version of Bun (which is v1.1.2)
PS C:\Work\Angular Study\DynamicHeader>

  1. Bun i

image

Laptop has AV tools like Symantec Endpoint security,Carbon Black,Rapid 7 etc installed.

What is the expected behavior?

I expected bun to install the project dependencies without crashing, regardless of the antivirus software running in the background.

What do you see instead?

Segmentation fault error on first try

Additional information

Installed AV tools

Symantec Endpoint Protection
Carbon Black
Rapid 7
Netskope

Activity

  1. changed the title [-]Segmentation Fault on commands like "bun i" and "bun upgrade" - When Executing Bun Commands with AV Software Active[/-] [+]Segmentation Fault on commands like "bun i" and "bun upgrade" - When Executing Bun Commands with AV Software Active on Windows[/+] on Apr 8, 2024
  2. changed the title [-]Segmentation Fault on commands like "bun i" and "bun upgrade" - When Executing Bun Commands with AV Software Active on Windows[/-] [+]Segmentation Fault on commands like "bun i" and "bun upgrade" - When Executing Bun Commands with AV Software Active on Windows[/+] on Apr 8, 2024
  3. added
    needs reproNeeds an example to reproduce
    windowsAn issue that is known to occur on Windows
    on Apr 8, 2024
  4. github-actions commented on Aug 8, 2024

    @github-actions
    Contributor

    This issue is stale and may be closed due to inactivity. If you're still running into this, please leave a comment.

  5. changed the title [-]Segmentation Fault on commands like "bun i" and "bun upgrade" - When Executing Bun Commands with AV Software Active on Windows[/-] [+]Segmentation Fault on commands like "bun i" and "bun upgrade" when Carbon Black AV Active on Windows[/+] on Oct 10, 2025
  6. marked bun exec crash - Windows #18588 as a duplicate of this issue on Oct 10, 2025
  7. marked bun init crash on windows #18587 as a duplicate of this issue on Oct 10, 2025
  8. jboyesreach00 commented on Oct 23, 2025

    @jboyesreach00

    still happening in 1.3.1
    I thought the windows file signing was supposed to fix it?

    Bun v1.3.1 (89fa0f3) on windows x86_64 [InstallCommand]

    Segmentation fault at address 0x8AEDE6B010

    Features: tsconfig, tsconfig_paths, binlinks, bunfig, lifecycle_scripts, text_lockfile, hoisted_bun_install, spawn

    Sentry Issue: BUN-ZJD

  9. marked Segmentation fault #25153 as a duplicate of this issue on Nov 27, 2025
  10. Casenl commented on Feb 5, 2026

    @Casenl

    For anyone reading this, it was fixed at my (work) laptop by adding a bypass rule in carbon black for these folders.
    c:\users*.bun\bin\bun.exe
    c:\users*.bun\bin\bun-windows-x64\bun.exe

  11. robobun commented on Jun 4, 2026

    @robobun
    Collaborator

    Root-cause analysis for the Windows uv_spawn crash family (Sentry groups BUN-2V2M — ~9,500 events — and BUN-Y5X; also #21693, #22344, #22930, #23460, #24260, #24828, #25153, #25299)

    TL;DR: these segfaults happen inside third-party endpoint-security hooks that intercept CreateProcessW — Carbon Black App Control's ctiuser.dll in most decoded reports, BeyondTrust Privilege Guard's PGHook.dll in some — not in Bun's own spawn code. Adding a Carbon Black approval/bypass rule for bun.exe (as confirmed in an earlier comment here) makes them disappear.

    What the stacks show

    Every decodable report in this family has the same sandwich:

    ??? in ctiuser.dll            ← crash PC
    ??? in ctiuser.dll
    ??? in KERNEL32.DLL
    ??? in KERNELBASE.dll         ← the real CreateProcessInternalW
    ??? in KERNELBASE.dll
    ??? in KERNEL32.DLL
    ??? in ctiuser.dll            ← hook entry
    uv_spawn        vendor libuv src/win/process.c:1067
    spawn           libuv.zig
    spawnProcess    process.zig
    

    process.c:1067 at the libuv revision pinned by bun 1.3.x is exactly the CreateProcessW(...) call inside uv_spawn. The frames above it are the security product's in-process hook wrapping that call, re-entering the real API, getting called back, and crashing on its own state — at 0x113 (near-null) in several reports, or at page-aligned heap addresses (e.g. 0xdc2d01e010 in this issue's original report) when its scanner reads past a committed heap region. In the Sentry events where these frames show only as <anonymous>, the PCs sit in module-less executable memory — hook trampolines — which is why they can't be attributed to any DLL at all.

    The "first command crashes, second run works" behavior reported above also matches Carbon Black App Control's first-execution analysis of not-yet-cached binaries, and explains why this appears as a steady background rate across Bun versions (1.3.10 → 1.3.14 equally affected) rather than a regression.

    Why it isn't a Bun argument/env bug

    To rule out Bun's side, every input handed to uv_spawn/CreateProcessW was audited across the spawn paths (Bun.spawn/spawnSync, node:child_process, the shell, bun install lifecycle scripts, bun run, bunx), on both the 1.3.x implementation and current main:

    • argv is always non-empty and NULL-sentinel-terminated; arg/env strings are NUL-terminated copies, with embedded NUL bytes rejected up front.
    • The env array gets its NULL sentinel appended before every spawn; inherited env comes from a sentinel-allocated map.
    • cwd and file/argv0 are explicitly NUL-terminated.
    • libuv's make_program_args / make_program_env / uv__stdio_create size-then-copy consistently, so the lpCommandLine / lpEnvironment / lpApplicationName / lpReserved2 buffers passed to CreateProcessW are well-formed given those inputs.
    • Bun 1.3.11–1.3.13 pinned unpatched upstream libuv (f3ce527e) and crash at the same rate as 1.3.14 (which added the ConPTY patch), so Bun's libuv fork changes are not a factor either.

    Workarounds

    • Carbon Black App Control (ctiuser.dll): have IT add an approval/bypass rule for bun.exe (and Bun-managed cache directories, e.g. %TEMP%\bunx-*, the install cache) — confirmed fix in this thread.
    • BeyondTrust Privilege Management (PGHook.dll): add an application exclusion for bun.exe.
    • Publishers bundling Bun (e.g. standalone executables) hit the same hooks; the exclusion needs to cover the bundled binary.

    Two unrelated, currently-unreachable libuv edge cases turned up during the audit (upstream already fixed the empty-argv command-line termination in libuv/libuv@e8575ba — worth picking up on the next fork rebase). Neither is reachable from Bun's spawn paths and neither explains this crash family.

  12. added 2 commits that reference this issue on Jul 22, 2026
    642e37b
    6c6ef82
  13. robobun commented on Jul 24, 2026

    @robobun
    Collaborator

    Fixed by #35083.

    Bun's Vectored Exception Handler no longer intercepts first-chance access violations raised outside bun.exe's own image, so SEH-guarded probes from injected DLLs (AV/EDR hooks, sandboxing, virtualization guest tools) reach their __except handler instead of being reported as a Bun crash.

    Verified the mechanism on Windows x64 canary 1.4.0-canary.1+50bb3bd8e:

    $ bun -e "require('bun:ffi').dlopen('kernel32.dll',{IsBadReadPtr:{args:['usize','usize'],returns:'i32'}}).symbols.IsBadReadPtr(0xE8,8); console.log('PASS: no crash')"
    PASS: no crash
    

    (Before #35083 this reported panic: Segmentation fault at address 0xE8.)

    If this still reproduces on a canary newer than 50bb3bd with the specific software installed, please reopen with the crash report link.

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

    bugSomething isn't workingneeds reproNeeds an example to reproducestalewindowsAn issue that is known to occur on Windows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions