oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.14k stars 2.76k forks source link

Bun.spawnSync segfaults on Windows macro #10467

Closed gitblit closed 2 months ago

gitblit commented 6 months ago

What version of Bun is running?

1.1.4+fbe2fe0c3

What platform is your computer?

Microsoft Windows NT 10.0.22631.0 x64

What steps can reproduce the bug?

index.ts

import { getGitCommitHash } from "./utils" with { type: "macro" };

console.log(`The current git commit is ${getGitCommitHash()}`);

utils.ts

// Bun build macro
export function getGitCommitHash() {
    const { stdout } = Bun.spawnSync({
      cmd: ["git", "rev-parse", "HEAD"],
      stdout: "pipe",
    });

    return stdout.toString().trim();
  }

console

bun run dev

What is the expected behavior?

Console should display:

The current git commit is 62b56d4e169308b2d4d96b3b6deb3118240dcdde

What do you see instead?

$ bun run --watch src/index.ts
Segmentation fault at address 0x68
???:?:?: 0x7ff61c1f89da in ??? (bun.exe)
???:?:?: 0x7ff61c1f7010 in ??? (bun.exe)
???:?:?: 0x1a59abc119d in ??? (???)
???:?:?: 0x425f56d043 in ??? (???)
???:?:?: 0x1a5989873cf in ??? (???)
???:?:?: 0x1a5988e096f in ??? (???)
error: script "dev" exited with code 3

Additional information

If I remove the syntax with { type: "macro" }, then it succeeds.

gitblit commented 6 months ago

Updated with crash reporter data introduced in 1.1.5.

Bun v1.1.5 (#10527) on windows x86_64 [RunCommand]

Segmentation fault at address 0x00000068

gitblit commented 5 months ago

Updated with crash reporter data from 1.1.8.

Bun v1.1.8 (89d2580) on windows x86_64 [RunCommand]

Segmentation fault at address 0x00000078

gitblit commented 2 months ago

This appears to have been resolved sometime between version1.1.8 and 1.1.26.