Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun WebSocket Segmentation Fault closing invalid connection #16995

Closed
hakt0r opened this issue Feb 2, 2025 · 1 comment · Fixed by #17101
Closed

Bun WebSocket Segmentation Fault closing invalid connection #16995

hakt0r opened this issue Feb 2, 2025 · 1 comment · Fixed by #17101
Labels
crash An issue that could cause a crash runtime

Comments

@hakt0r
Copy link

hakt0r commented Feb 2, 2025

How can we reproduce the crash?

Description

Bun crashes with a segmentation fault when attempting to close a WebSocket connection to an invalid/unreachable URL.

Minimal Reproduction

Since you insist: REPRO-REPO

import { test } from 'bun:test';

test('crash', async () => {
  const publicAddress = new URL('https://1.1.1.1:3000');
  const socket = new WebSocket(publicAddress.toString());
  // crashes -- comment this out to see the test pass
  socket.close();
});

Environment

  • Bun version: 1.2.2-canary.9
  • OS: Linux x64 (Kernel v6.12.9)
  • CPU Features: sse42 popcnt avx avx2

Steps to Reproduce

  1. Create a new file crash.test.js with the code above
  2. Run bun test crash.test.js

Expected Behavior

The WebSocket should handle the invalid connection gracefully, either:

  • Throwing a network error
  • Failing to connect but allowing close() to be called
  • Returning a rejected promise

Actual Behavior

Bun crashes with a segmentation fault at address 0x0

Relevant log output

bun test v1.2.2-canary.9 (aac951bd)

bundled.crash.test.js:
============================================================
Bun Canary v1.2.2-canary.9 (aac951bd) Linux x64
Linux Kernel v6.12.9 | glibc v2.40
CPU: sse42 popcnt avx avx2
Args: "/home/awt/Downloads/cursor-0.45.8-build-250201b44xw1x2k-x86_64.AppImage" "test" "bundled.crash.test.js"
Features: WebSocket jsc 
Elapsed: 16ms | User: 8ms | Sys: 21ms
RSS: 1.07GB | Peak: 40.28MB | Commit: 1.07GB | Faults: 0

panic(main thread): Segmentation fault at address 0x0
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.2.2/lt2aac951bAwggEo2rnoE+5+P27l24DigkxkE_g2qr9Dghir9Dg2qr9Dmsoj9Duk6x8EA2AA

Stack Trace (bun.report)

bun.report comes up with internal server error

https://bun.report/1.2.2/lt2aac951bAwggEo2rnoE+5+P27l24DigkxkE_g2qr9Dghir9Dg2qr9Dmsoj9Duk6x8EA2AA

@hakt0r hakt0r added the crash An issue that could cause a crash label Feb 2, 2025
@Jarred-Sumner
Copy link
Collaborator

I haven’t been able to reproduce this on Linux or macOS. We will have address sanitizer working early this week and hopefully it will reproduce there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash An issue that could cause a crash runtime
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants