[GH-ISSUE #3042] [macOS] Client crashes (SIGSEGV) on auto-reconnect after wake from sleep with Xray — 5.0.1.5 #1401

Open
opened 2026-10-13 20:41:41 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @egkostin on GitHub (Aug 25, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3042

report.txt

Describe the bug

The desktop GUI client crashes with EXC_BAD_ACCESS (SIGSEGV) about 30 seconds after the Mac wakes from sleep, while auto-reconnecting an Xray/VLESS connection. Full macOS crash report attached.

Crashing thread is the VpnConnection worker thread:

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
KERN_INVALID_ADDRESS at 0x0000000000000430

Thread 3 Crashed:: QThread
0   QtCore       0x1062f6e5c 0x10620c000 + 962140
1   AmneziaVPN   VpnProtocol::connectionStateChanged(Vpn::ConnectionState) + 60
2   AmneziaVPN   VpnProtocol::setConnectionState(Vpn::ConnectionState) + 656
3   AmneziaVPN   XrayProtocol::stop() + 1844
4   AmneziaVPN   VpnConnection::reconnectToVpn() + 244
5   QtCore       QObject::event(QEvent*) + 672
6   QtCore       QCoreApplicationPrivate::sendPostedEvents(...)

Possible cause

Reading the 5.0.1.5 sources, the crash looks like the emit connectionStateChanged(...) on the last line of XrayProtocol::stop() running on an object that is no longer alive:

  • wakeup and networkChanged are connected to VpnConnection::reconnectToVpn in createProtocolConnections() (client/vpnConnection.cpp:387-390). That method runs on every connect and never disconnects the previous connections, so the number of queued reconnectToVpn invocations per single wake-up grows with each connect/disconnect cycle in a session.
  • XrayProtocol::stop() (client/core/protocols/xrayProtocol.cpp:119-166) makes five synchronous IPC calls with waitForFinished(), each spinning a nested event loop — so those extra queued reconnectToVpn events get delivered while stop() is still on the stack.
  • Re-entering the reconnect path resets/replaces m_vpnProtocol, so setConnectionState(Disconnected) at the end of stop() fires on a freed object.

This may be the client-side counterpart of #2637, which describes the same kind of race in AmneziaVPN-service.

To Reproduce

Approximate — the exact number of connect/disconnect cycles before the crash isn't known:

  1. Connect with Xray/VLESS on macOS
  2. Leave the VPN connected and let the Mac sleep (close the lid)
  3. Wake it up
  4. The app crashes within ~30 s

Expected behavior

The client reconnects after wake without crashing.

Log files

report.txt attached (full macOS crash report). The app had been running 1 h 34 min; Time Since Wake: 30 seconds at the moment of the crash.

Desktop:

  • OS: macOS 26.6.2 (25G83), Apple M2 Pro (Mac14,9), arm64
  • Version: 5.0.1.5, installed as .pkg, Qt 6.10
  • Protocol: Xray / VLESS

Additional context

I'm not a developer — the crash report is genuine, but the stack-trace analysis above was done with an AI assistant against the 5.0.1.5 sources, so please treat that part as a hypothesis rather than a verified diagnosis.

Originally created by @egkostin on GitHub (Aug 25, 2026). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3042 [report.txt](https://github.com/user-attachments/files/31418374/report.txt) **Describe the bug** The desktop GUI client crashes with `EXC_BAD_ACCESS (SIGSEGV)` about 30 seconds after the Mac wakes from sleep, while auto-reconnecting an Xray/VLESS connection. Full macOS crash report attached. Crashing thread is the `VpnConnection` worker thread: ``` Exception Type: EXC_BAD_ACCESS (SIGSEGV) KERN_INVALID_ADDRESS at 0x0000000000000430 Thread 3 Crashed:: QThread 0 QtCore 0x1062f6e5c 0x10620c000 + 962140 1 AmneziaVPN VpnProtocol::connectionStateChanged(Vpn::ConnectionState) + 60 2 AmneziaVPN VpnProtocol::setConnectionState(Vpn::ConnectionState) + 656 3 AmneziaVPN XrayProtocol::stop() + 1844 4 AmneziaVPN VpnConnection::reconnectToVpn() + 244 5 QtCore QObject::event(QEvent*) + 672 6 QtCore QCoreApplicationPrivate::sendPostedEvents(...) ``` **Possible cause** Reading the 5.0.1.5 sources, the crash looks like the `emit connectionStateChanged(...)` on the last line of `XrayProtocol::stop()` running on an object that is no longer alive: - `wakeup` and `networkChanged` are connected to `VpnConnection::reconnectToVpn` in `createProtocolConnections()` (`client/vpnConnection.cpp:387-390`). That method runs on every connect and never disconnects the previous connections, so the number of queued `reconnectToVpn` invocations per single wake-up grows with each connect/disconnect cycle in a session. - `XrayProtocol::stop()` (`client/core/protocols/xrayProtocol.cpp:119-166`) makes five synchronous IPC calls with `waitForFinished()`, each spinning a nested event loop — so those extra queued `reconnectToVpn` events get delivered while `stop()` is still on the stack. - Re-entering the reconnect path resets/replaces `m_vpnProtocol`, so `setConnectionState(Disconnected)` at the end of `stop()` fires on a freed object. This may be the client-side counterpart of #2637, which describes the same kind of race in AmneziaVPN-service. **To Reproduce** Approximate — the exact number of connect/disconnect cycles before the crash isn't known: 1. Connect with Xray/VLESS on macOS 2. Leave the VPN connected and let the Mac sleep (close the lid) 3. Wake it up 4. The app crashes within ~30 s **Expected behavior** The client reconnects after wake without crashing. **Log files** `report.txt` attached (full macOS crash report). The app had been running 1 h 34 min; `Time Since Wake: 30 seconds` at the moment of the crash. **Desktop:** - OS: macOS 26.6.2 (25G83), Apple M2 Pro (Mac14,9), arm64 - Version: 5.0.1.5, installed as .pkg, Qt 6.10 - Protocol: Xray / VLESS **Additional context** I'm not a developer — the crash report is genuine, but the stack-trace analysis above was done with an AI assistant against the 5.0.1.5 sources, so please treat that part as a hypothesis rather than a verified diagnosis.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#1401
No description provided.