oven-sh / bun

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

Bun segfaults when building library #14018

Closed mreinertssgr closed 1 month ago

mreinertssgr commented 1 month ago

How can we reproduce the crash?

I'm creating a simple library, that unfortunately I cannot share. This is my build file and the relevant parts of package.json

import dts from 'bun-plugin-dts';

await Bun.build({
    entrypoints: ['./src/index.ts'],
    outdir: './dist',
    minify: true,
    plugins: [dts()],
});
  "types": "dist/index.d.ts",
  "type": "module",
  "main": "dist/index.js",
  "scripts": {
    "build": "bun run build.mjs",
    "prepublishOnly": "bun run build"
  },
  "devDependencies": {
    "@biomejs/biome": "1.9.1",
    "@types/bun": "^1.1.9",
    "bun-plugin-dts": "^0.2.3"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  },
  "dependencies": {
    "@types/argon2-browser": "^1.18.4",
    "argon2-browser": "^1.18.0"
  }

Relevant log output

❯ bun run build
$ bun run build.mjs
============================================================
Bun Canary v1.1.28-canary.79 (b66d622c) macOS Silicon
macOS v14.5
Args: "bun" "run" "build.mjs"
Features: jsc transpiler_cache(2) tsconfig_paths tsconfig
Builtins: "bun:main" "node:buffer" "node:crypto" "node:fs" "node:module" "node:os" "node:path" "node:perf_hooks" "node:string_decoder" "node:util/types"
Elapsed: 725ms | User: 1847ms | Sys: 87ms
RSS: 0.49GB | Peak: 0.49GB | Commit: 1.05GB | Faults: 56

panic: Segmentation fault at address 0x4
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

To send a redacted crash report to Bun's team,
please file a GitHub issue using the link below:

 https://bun.report/1.1.28/Mr2b66d622AigggwD__+k61Bm+06Xuxo2W__A2AI

error: script "build" was terminated by signal SIGTRAP (Trace or breakpoint trap)
zsh: trace trap  bun run build

Stack Trace (bun.report)

Bun v1.1.28 (b66d622) on macos aarch64 [RunCommand]

Segmentation fault at address 0x00000004

dylan-conway commented 1 month ago

Do you import any wasm files? If so, I believe #14047 will fix this crash

shinobu-uwu commented 1 month ago

Yes, argon2-browser communicates with the C implementation via wasm.

That's great to hear, is there any ETA for a release including this fix?

mreinertssgr commented 1 month ago

Using bun canary I can confirm it's been fixed, the library builds as expected

dylan-conway commented 1 month ago

Great

@shinobu-uwu the fix was included in the most recent release, bun v1.1.29