oven-sh / bun

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

Segmentation Fault while doing "bun install" or bun add #4950

Open Bufige opened 10 months ago

Bufige commented 10 months ago

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Linux 6.4.4-arch1-1 x86_64 unknown

What steps can reproduce the bug?

run the command below or have it in your project.

bun add serverless-dotenv-plugin

or

bun install

package.json

{
  "name": "bun-install",
  "module": "index.ts",
  "type": "module",
  "devDependencies": {
    "bun-types": "latest",
    "serverless-dotenv-plugin": "6.0.0"
  },
  "peerDependencies": {
    "typescript": "^5.0.0"
  }
}

What is the expected behavior?

install it

What do you see instead?

12228 segmentation fault (core dumped) bun add serverless-dotenv-plugin

Additional information

No response

Hanaasagi commented 10 months ago

coredump stack

#0  0x00007fa73cc8e83c in ?? () from /usr/lib/libc.so.6
#1  0x00007fa73cc3e668 in raise () from /usr/lib/libc.so.6
#2  0x00007fa73cc264b8 in abort () from /usr/lib/libc.so.6
#3  0x0000561ec0057a39 in os.abort () at /home/kumiko/zig/zig-linux-x86_64-0.12.0-dev.163+6780a6bbf/lib/std/os.zig:598
#4  0x0000561ec0053744 in debug.panicImpl (trace=0x0, first_trace_addr=..., msg=...)
    at /home/kumiko/zig/zig-linux-x86_64-0.12.0-dev.163+6780a6bbf/lib/std/debug.zig:440
#5  0x0000561ec0052464 in src.main.panic (msg=..., error_return_trace=0x0, addr=...) at /home/kumiko/zig/bun/src/main.zig:88
#6  0x0000561ec02d3a6f in src.install.semver.Query.Token.toRange (this=..., version=...)
    at /home/kumiko/zig/bun/src/install/semver.zig:1578
#7  0x0000561ec02d3254 in src.install.semver.Query.parse (allocator=..., input=..., sliced=...)
    at /home/kumiko/zig/bun/src/install/semver.zig:1923
#8  0x0000561ec02ded8c in src.install.dependency.parseWithTag (allocator=..., alias=..., dependency=..., tag=npm,
    sliced=0x7ffd3bf3b7f0, log_=0x561ec30f1560 <src.cli.Cli.log_>) at /home/kumiko/zig/bun/src/install/dependency.zig:680
#9  0x0000561ec02ddb15 in src.install.dependency.parseWithOptionalTag (allocator=..., alias=..., dependency=..., tag=...,
    sliced=0x7ffd3bf3b7f0, log=0x561ec30f1560 <src.cli.Cli.log_>) at /home/kumiko/zig/bun/src/install/dependency.zig:636
#10 0x0000561ec0337633 in src.install.lockfile.Package.fromNPM__anon_72648 (allocator=..., lockfile=0x2b610030000,
    log=0x561ec30f1560 <src.cli.Cli.log_>, manifest=0x2b6101c0cc0, version=..., package_version_ptr=0x2b6101fb360, string_buf=...)
    at /home/kumiko/zig/bun/src/install/lockfile.zig:2190
#11 0x0000561ec033d91b in src.install.install.PackageManager.getOrPutResolvedPackageWithFindResult__anon_72647 (
    this=0x561ec2b9bd08 <src.install.install.PackageManager.instance>, name_hash=2134973033570712245, name=..., version=...,
    dependency_id=14, behavior=(unknown: 0x2), manifest=0x2b6101c0cc0, find_result=...)
    at /home/kumiko/zig/bun/src/install/install.zig:2411
#12 0x0000561ec033ff23 in src.install.install.PackageManager.getOrPutResolvedPackage__anon_72642 (
    this=0x561ec2b9bd08 <src.install.install.PackageManager.instance>, name_hash=2134973033570712245, name=..., version=...,
    behavior=(unknown: 0x2), dependency_id=14, resolution=4294967295) at /home/kumiko/zig/bun/src/install/install.zig:2568
#13 0x0000561ec0350d5c in src.install.install.PackageManager.enqueueDependencyWithMainAndSuccessFn__anon_72519 (
    this=0x561ec2b9bd08 <src.install.install.PackageManager.instance>, id=14, dependency=0x7ffd3bf43b30, resolution=4294967295)
    at /home/kumiko/zig/bun/src/install/install.zig:2882
#14 0x0000561ec0355e08 in src.install.install.PackageManager.enqueueDependencyWithMain (
    this=0x561ec2b9bd08 <src.install.install.PackageManager.instance>, id=14, dependency=0x7ffd3bf43b30, resolution=4294967295)
    at /home/kumiko/zig/bun/src/install/install.zig:2850
#15 0x0000561ec039151f in src.install.install.PackageManager.installWithManager__anon_71770 (
    manager=0x561ec2b9bd08 <src.install.install.PackageManager.instance>, ctx=..., package_json_contents=...)
    at /home/kumiko/zig/bun/src/install/install.zig:7600
#16 0x0000561ec039d3f4 in src.install.install.PackageManager.updatePackageJSONAndInstallWithManagerWithUpdates__anon_71620 (
--Type <RET> for more, q to quit, c to continue without paging--
    manager=0x561ec2b9bd08 <src.install.install.PackageManager.instance>, ctx=..., updates=..., auto_free=false) at /home/kumiko/zig/bun/src/install/install.zig:6421
#17 0x0000561ec039e5a7 in src.install.install.PackageManager.updatePackageJSONAndInstallWithManager__anon_71567 (manager=0x561ec2b9bd08 <src.install.install.PackageManager.instance>, ctx=...) at /home/kumiko/zig/bun/src/install/install.zig:6234
#18 0x0000561ec03e5f2a in src.install.install.PackageManager.updatePackageJSONAndInstall__anon_71045 (ctx=...) at /home/kumiko/zig/bun/src/install/install.zig:6131
#19 0x0000561ec03e6661 in src.cli.add_command.AddCommand.exec (ctx=<error reading variable: Cannot access memory at address 0x14b83f>) at /home/kumiko/zig/bun/src/cli/add_command.zig:6
#20 0x0000561ec04abb5d in src.cli.Command.start (allocator=..., log=0x561ec30f1560 <src.cli.Cli.log_>) at /home/kumiko/zig/bun/src/cli.zig:1309
#21 0x0000561ec00548e6 in src.cli.Cli.start__anon_4597 (allocator=...) at /home/kumiko/zig/bun/src/cli.zig:57
#22 0x0000561ec00528af in src.main.main () at /home/kumiko/zig/bun/src/main.zig:41
#23 0x0000561ec00522cd in main (c_argc=3, c_argv=0x7ffd3bf60248, c_envp=0x7ffd3bf60268) at /home/kumiko/zig/zig-linux-x86_64-0.12.0-dev.163+6780a6bbf/lib/std/start.zig:467

panic at

https://github.com/oven-sh/bun/blob/51d3d4382281f789f8175079ed426a63529eb3e7/src/install/semver.zig#L1578

xn1cklas commented 10 months ago

Not sure if this applies to serverless env as well, but bun has built in .env support: https://bun.sh/guides/runtime/set-env

Bufige commented 10 months ago

The problem is related to the 'peerDependencies' in the package.json. I was testing to see what was the problem by removing features in the package and i come up with this. This is 100% reproducible.

{
  "name": "serverless-dotenv-plugin",
  "version": "6.0.0",
  "description": "Preload environment variables with dotenv into serverless.",
  "main": "src/index.js",
  "files": [
    "src/**/*"
  ],
  "dependencies": {    
  },
  "devDependencies": {

  },
  "peerDependencies": {
    "serverless": "1 || 2 || pre-3 || 3"
  }
}
mgomez-tubs commented 7 months ago

Same error during install, rerunning bun install didn't show the error again

nektro commented 6 months ago

does this still reproduce for you?

image image
huilensolis commented 5 months ago

hi, I'm having the same issue.

bun i
bun install v1.0.25 (a8ff7be6)
  🔍 execa [11/200] zsh: segmentation fault (core dumped)  bun i

If I run bun i again, the error disappears, but in some cases, it happens again.

My download speed is 4 mbit/s rn and im running bun 1.0.25 on Linux 6.5.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Sat, 23 Sep 2023 22:55:13 +0000 x86_64 GNU/Linux

huilensolis commented 4 months ago

I'm having the same error again, this time running on bun 1.0.35

Jarred-Sumner commented 2 months ago

The original bug was fixed some time ago by @dylan-conway

@Huilensolis can you provide a stack trace for a more recent version of Bun?

huilensolis commented 2 months ago

hi, this error occurs occasionally. so I cant replicate it. if I face it again, I will make sure to report it here!