Safari (Mac Only) crashes when using websocket
Problem
I am using the very basic example listed on the website, not sending or receiving any messages, just connecting. Connection is on 127.0.0.1:80 On connect Safari crashes with following: Process: Safari [11081] Path: /Applications/Safari.app/Contents/MacOS/Safari Identifier: com.apple.Safari Version: 5.0.5 (6533.21.1) Build Info: WebBrowser-75332101~1 Code Type: X86-64 (Native) Parent Process: launchd [238] Date/Time: 2011-04-23 02:40:30.463 -0400 OS Version: Mac OS X 10.6.7 (10J869) Report Version: 6 Interval Since Last Report: 140807 sec Crashes Since Last Report: 20 Per-App Interval Since Last Report: 36857 sec Per-App Crashes Since Last Report: 16 Anonymous UUID: 545FB01F-FF2E-4A16-9EFC-A8A538906A53 Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000 Crashed Thread: 0 Dispatch queue: com.apple.main-thread Thread 0 Crashed: Dispatch queue: com.apple.main-thread 0 com.apple.CoreFoundation 0x00007fff87e11c00 CFArrayGetCount + 80 1 com.apple.WebCore 0x00007fff82a3150b WebCore::SocketStreamHandle::chooseProxyFromArray(__CFArray const_) + 43 2 com.apple.WebCore 0x00007fff82cc6088 WebCore::SocketStreamHandle::pacExecutionCallbackMainThread(void_) + 24 3 com.apple.JavaScriptCore 0x00007fff87bf6848 WTF::callOnMainThreadAndWait(void (_)(void_), void_) + 72 4 com.apple.WebCore
Error Output
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Update Safari and WebSocket Implementation
The crash in Safari when connecting to a WebSocket on 127.0.0.1:80 is likely due to a bug in the WebCore networking stack that mishandles the connection process, particularly in older versions of Safari (5.0.5) and Mac OS X (10.6.7). The EXC_BAD_ACCESS (SIGSEGV) error indicates that the application is trying to access a null pointer, which can occur if the WebSocket implementation does not properly handle the connection lifecycle or proxy settings.
Awaiting Verification
Be the first to verify this fix
- 1
Update Safari
Ensure that Safari is updated to the latest version available for your macOS. This can resolve known bugs and improve WebSocket handling.
bashsudo softwareupdate --install --all - 2
Switch to a Different Port
Change the WebSocket server to use a different port (e.g., 8080) instead of 80. This can help avoid conflicts with existing services and may bypass the issue.
javascriptconst socket = new WebSocket('ws://127.0.0.1:8080'); - 3
Disable Proxy Settings
Check and disable any proxy settings in Safari that may interfere with WebSocket connections. Go to System Preferences > Network > Advanced > Proxies and ensure no proxies are enabled.
noneN/A - 4
Test with a Different Browser
As a temporary workaround, test the WebSocket connection using a different browser (e.g., Chrome or Firefox) to confirm that the issue is specific to Safari.
noneN/A - 5
Review WebSocket Implementation
Ensure that the WebSocket server is correctly implemented and does not have any issues that could cause crashes. Review the server logs for any errors during connection attempts.
noneN/A
Validation
After implementing the above steps, attempt to connect to the WebSocket again. If Safari does not crash and the connection is established successfully, the issue is resolved. Additionally, check for any error messages in the console.
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep