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

Crash in TLS socket finalizer #13168

Closed Leni-Vienne closed 3 months ago

Leni-Vienne commented 3 months ago

How can we reproduce the crash?

Call some express routes a few times. They have postgres queries for most of them, using the 'pg' package. This crash does not happen in bun 1.20. I would like to test bun 1.21 but I am behind a company proxy so downgrading via the curl command doesn't work. Interestingly, it says I am on Bun Canary despite the fact I just uninstalled and re-installed Bun

Relevant log output

============================================================
Bun Canary v1.1.22-canary.96 (df33f2b2) Windows x64 (baseline)
CPU: sse42
Args: "D:\Users\leni.vienne\.bun\bin\bun.exe" "--env-file=../.env" "--hot" "run" "server.js"
Features: jsc dotenv http_server transpiler_cache(4) tsconfig(7) no_avx no_avx2
Builtins: "bun:main" "node:assert" "node:async_hooks" "node:buffer" "node:crypto" "node:dns" "node:events" "node:fs" "node:http" "node:net" "node:path" "node:querystring" "node:stream" "node:string_decoder" "node:tls" "node:tty" "node:url" "node:util" "node:util/types" "node:zlib"
Elapsed: 738032ms | User: 2406ms | Sys: 1390ms
RSS: 0.26GB | Peak: 0.26GB | Commit: 0.36GB | Faults: 149457

Stack Trace (bun.report)

Bun v1.1.22 (df33f2b) on windows x86_64_baseline [RunCommand]

Segmentation fault at address 0x2F00000057

Jarred-Sumner commented 3 months ago

This crash is unrelated to express. Can you include the source code for us to reproduce it?

Leni-Vienne commented 3 months ago

Okay I've been struggling to narrow it down It can occur :

It rarely crashes twice on the same line, which makes it very hard to narrow it down. It feels like there is an instability somewhere. I don't know if my code will be of much help but If you want it, how can I give it to you privately?

Here is the crash from the openstack container, running the same code :

Bun v1.1.22 (df33f2b) on linux x86_64_baseline [AutoCommand]

Segmentation fault at address 0x00000000

And another example from right now, this one failed specifically at a postgres query, I had console.log before and after it :

Bun v1.1.22 (df33f2b) on windows x86_64_baseline [RunCommand]

Segmentation fault at address 0x00000041

A crash right after saving a .js file in --hot mode :

Bun v1.1.22 (df33f2b) on windows x86_64_baseline [RunCommand]

Segmentation fault at address 0x2F00000057

Jarred-Sumner commented 3 months ago

I think @cirospaciari has a fix in #13176

if you go to the Buildkite link in there and click on artifacts under build-bun x64 windows you could test it out

Jarred-Sumner commented 3 months ago

Fixed in https://github.com/oven-sh/bun/pull/13176