mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-10-14 13:52:12 +00:00
[GH-ISSUE #3146] Windows: tun2socks crashes with 0xc0000005 while using XRay/VLESS+Reality+XHTTP, causing Error 804 #1460
Open
opened 2026-10-13 20:42:53 +00:00 by bsakaguchi
·
4 comments
No Branch/Tag specified
dev
feat/gateway-service-import-test
feat/api-tests
fix/serialize-log-record-writes-and-pin-log-date-format-locale
fix/libagw-review-fixes
feat/otp-login
fix/ios-xray-ipv6-leak
fix/macos-xray-ipv6-leak
feat/add-support-include-split-tunnel
fix/win-xray-app-split-tunneling
fix/bug-when-saving-after-canceling
fix/xray-reconnect-crash
fix/share-empty-config-on-ssh-timeout
fix/ssh-credentials-input
fix/updater-verify-signature
fix/async-ssh-threading
fix/xray-check-inet-and-liveness-monitor
fix/selfhosted-server-installations
feat/add-support-ikev2-macos
fix/icons-different-color-themes
feat/add_support_arm_windows
feat/add-deep-link
feat/fixed-push-notifications-on-VPN-connect-disconnect-2
feat/implement-QR-code-generation-and-scanning
feat/file-password-protection
feature/add-local-proxy
feat/add-support-split-tunnel-macos
feat/tests
fix/android-register-unacknowledged-purchase
fix/share_on_linux
mirroring-to-outside
feat_copy_docker_configs
feat/self-diagnostics-log
feat/amnezia-free-vless-switch
fix/conan_build_android_on_win
fix/linux-reconnect-dns-reliability
fix/windows-connection-stability
fix/linux-reconnect-refactoring
fix/ios-groupidentifier-order
feat/xray-subscription-link
fix/minor-fixes
fix/xray-config-inplace-edit
feat/amnezia-sdk-typed-api
feat/amnezia-sdk-integration
feat/force-update-native
refactor/marketplace-update-popup
feat/force-update
fix/valnurability_dev
chore-xcode-version
fix/empty-i1-i5
build_qt_6_10_1
master
feat/protocol-selection
fix/openvpn_install
feat/locations_change
feat/locations_change_rework
feature/local-proxy-integration
fix/filepicker_atv
fix_valnurability
fix/macos-ne-codesign-4.8.19.0
temp-branch-for-testing
fix/rebased_4_8_19_linux_fix_error
feat/proxy-storage-cache
fix/zeroed-params
fix/killswitch-blocknets-linux
update/translation_RU
fix/self_hosted_reinstall_error
feat/selfhosted-dns
fix/agp_version_up
feat/switch_to_alive_protocol
feat/support_multipeer
server_scripts_update
fix/extended-vless-configuration
chore/apple-ci-cd-macos-versions
feat/add-telemt
fix/android_keystore_read_error
feat/add-mtproxy
chore/bump-qt-version
fix/make_dbus_async
feature/dns
rebase/apple-tv-target-on-conan
fix/outbound_freedom_xray_with_dns_fix
feat/apk_support
feat/fallback-proxy
feat/apple-tv-target
fix/dns_reconnection_issue
feat/fixed-push-notifications-on-VPN-connect-disconnect
fix/linux-firewall
docker-regional-locks
appstore-review-popup
feat/storekit2
fix/uninstall-split-tunnelling-driver
revert-2376-chore/license-file
support_16kb_android
bump_version
feat_add_review_android
bugfix/translation-absence-on-subscription-key-page
feat/location-separation-by-region
bugfix/text-moving-when-resing-window
fix_backup
feature/add-purchase-android
bugfix/moved-text-while-resizing-window
bugfix/incorrect-killswitch-restore-from-backup
fix/backup-exclude-secondary-api-configs
feat/proxy-fields-for-dev-console
bugfix/ovpn-ios-fix
bugfix/linux-bundle-libraries
fix/xray-app-split-win
fix/upload-to-s3
chore/add-release-date-upload
feat_add_webview_support
feature/configuration-transfer-through-qr
feat/bot-key-unlink-device
fix/ad-link-lang-support
fix/qsecuresettings-with-android
feat/add-support-arm64-win
spanish-translations
fix/context-menu
feat/add-system-dns-support
fix/qt6-9-support
fix/qt6_9_support
bugfix/strict-killswitch-ui
android-7
chore/minor-bugfixes
feature/awg-net-fix-macos-wakeup
fixbug/ios18
bugfix/ios-ne-crash
fix/linux-tray-quit-button
cryptpad-support
bugfix/disable-linux-killswitch
fix/minor-ui-fixes
feature/setup-guid-tun2socks
feature/linux-ipsec
feature/ipsec-linux
refactoring/server-config-in-classes
feature/macos-ipsec
fix/ui-fixes-after-merge-with-d20ed4a
chore/focus_control_after_qt_6.9_migration
feature/integrate-xray-as-a-library
maxos-awg-fix
feature/add-new-awg-docker-image
chore/update-3rd-prebuild
feature/test-news
fix/api-conf-files
bugfix/split-tunneling-with-api-config
bugfix/ios-awg-new-fields
feature/special-handshake-2
feat/xray-api-support
fix/desktop-entry
bugfix/shadowsocks-cipher-setting-not-changing
feature/update-tap
bugfix/openvpn_import_fix
feature/ability-to-change-port-after-installing-xray
bugfix/strict-mode-ovpn
bugfix/win-ipv6-ovpn
bugfix/subnet-adress-setting
exception-podman-docker
bugfix/fix-listviewtype-scrolling
bugfix/win-disabled-ipv6
bugfix/win-ipv6-disabled-ovpn
feature/killswitch-strict-mode
feature/awg-network-check
feature/empty-split-tunneling-list
feature/support-info
chore/update-go-version
checking-Linux-version
update_server_scripts
bugfix/button-selection-easy-setup-page
feature/old-api-proxy
patch/user-checking
fix/correcting-version
support-podman
support_podman
user-checking-patch
feature/check-docker-version
feature/allowed-dns-list
without_lsof
chore/error-body
Update-amneziavpn_ru_RU
shiroow-patch-8
shiroow-patch-7
shiroow-patch-6
shiroow-patch-5
shiroow-patch-4
shiroow-patch-3
shiroow-patch-2
shiroow-patch-1
check_sudo_permissions
feature/euphoria
add_next_octet_to_ip_settings
bugfix/mobile-controllers-init
euphoria
bugfix/android-crush
feature/macox-network-extension
bugfix/pre-release-hotfixes
bugfix/ipsec-pfs
chore/ios-site-links
checking_sudo_permissions
feature/android-tv
improve_navigation_cpp
bugfix/linux-firewall-install
fixbug/wireguard-handshake-time
ReadmeRu_full
feature/xray-user-management
feature/subscription-end-date
chore/clang-format
feature/ru-in-readme
chore/increased-api-timeout
chore/deploy-workflow
bugfix/services-list-scroll
wheel_group_suppor
chore/bump-xcode-version
fixbug/mac-network-extension
feature/android-gpb
feature/page-home-drawer-country-selection
checking-sudo-users
bugfix/service-info-from-response
fixbug/build-macos-ne-2
android-qt-6.7.3
fixbug/build-macos-ne
bugfix/wg-windows-log-folder
feature/psk-key-api-request
bugfix/user-management-qml-warnings
fix/macos-network-extension
fixbug/macos-NE-build
bugfix/fixed-isDevEnv-initialization
bugfix/revert-ios-ovpn
feature/tun2socksSrv
fix/disable_singleapp
feature/awg-wg-name-resolving
feature/disable-dhcp
bugfix/allowed-ips-old-configs
feature/goodbyedpi
feature/add-exception-log
refactoring/remove-ipv6-from-default-routes
refactoring/singleapplication-submodule
macos-dirty-build
test/gateway
Update-amneziavpn_fa_IR.ts
bugfix/ipsec-win
fix/xray-custom-port
improve-tab-navigation
test-win-11
feature/android-tv-remote-control-support
KsZnak-patch-1
feature/awg-wg-qr
bugfix/fix-loopback-splittunel
fix/setup_host_firewall
feature/android-xray
feature/openvpn-pass
feature/connection-string
fix/clickable-errors
bugfix/api_1100_fix
feature/graphview
testsvg
feature/update-win-awg
feature/open-as-amnezia
feature/update-mozilla-upstream
bugfix/qr-code-cutting
feature/native-wg-psk
test/awg-centos
bugfix/hide_error
feature/add-uninstaller-checkbox
bugfix/cancel-button-on-install-page
bugfix/anchors-page-home-warning
awg-udptlspipe
button-focus-fix
revert-677-fix/logger
bugfix/Revert_PR_596
bugfix/allowed-ips-api-configs
bugfix/on-escape-pressed
feature/auto-scroll-for-server-selection-list
fix/ui-fixes
translations/update_fa_IR.ts
feature/new-awg-docker-container
bugfix/awg_ipv6_fix
feature/tab-navigation
fix/username-no-autocapitalization
sure
refactoring/servers-model-cleanup
feature/wg-mtu-setup-ios
3rd_adaptation_to_diff_OS
sudo_not_found
test/docker-ce
bugfix/double_clear_server_from_amnezia
fix/android
client/3rd-prebuilt
revert-559-KsZnak-translation-ru-ex
KsZnak-translation-ru-ex
KsZnak-br1
KsZnak-text-change
feature/api-awg
feature/error-code-output
feature/win_x32_builds
text/debug-output
feature/ovpn3-desktop-cli
bugfix/secureqsettings-deadlock
refactoring/change-settings-when-connected
files_check
ArchLinux-support
second_adaptation_to_diff_os
sudo
refactoring/android-build
adaptation_to_different_os
feature/online_installer_for_v4
update_to_r2
bugfix/return-after-installation
feature/custom_drawer_component
bugfix/split-tunneling
bugfix/existing-awg-container
revert-370-feature/custom_drawer_component
bugfix/adapted_awg_questiondrawer
bugfix/updated_drawer_height_pageserverdata
bugfix/translated_new_source_strings_to_chinese
feature/split-tunneling-config
feature/accessibility-support
branch_connectivity_change_fix
feature/ikev2_android
android_ss_transport
bugfix/macos_fixes
feature/nextcloud-support
feature/macos_network_extension
android_pt_transport_source
feature/ios-openvpn3-pluggable-transport-Cloak
bugfix/cloak_for_desktops_fix
arm-build-macos
fix-macos-build-brew
bugfix/ios-build-openvpnadapter-from-source
feature/download-native-wireguard-config-on-connect
feature/v2ray-container
bugfix/dpkg-busy-checking-stuck
feature/online-installer
dev-killswitch
dev-netadapters
5.0.3.0
5.0.2.1
5.0.2.0
5.0.1.5
5.0.0.5
5.0.0.2
4.8.21.0
4.8.19.0
4.8.18.0
4.8.17.0
4.8.16.0
4.8.15.4
4.8.15.0
4.8.14.5
4.8.14.1
4.8.12.9
4.8.12.8
4.8.12.7
4.8.12.6
4.8.11.4
4.8.11.3
4.8.11.2
4.8.11.1
4.8.11.0
4.8.10.0
4.8.9.2
4.8.9.1
4.8.9.0
4.8.8.3
4.8.8.2
4.8.8.1
4.8.7.2
4.8.7.1
4.8.7.0
4.8.6.0
4.8.5.0
4.8.4.5
4.8.4.4
4.8.4.3
4.8.4.2
4.8.4.1
4.8.4.0
4.8.3.2
4.8.3.1
4.8.2.3
4.8.1.9
4.8.1.0
4.8.0.5
4.7.0.0
4.6.0.3
4.6.0.1
4.5.3.0
4.5.0.0
4.4.0.0
4.3.0.0
4.2.1.0
4.2.0.1
4.1.2.0_cloak_pt_experimental
4.1.0.1
4.0.8
3.1.0
3.0.8
3.0.7
3.0.5
2.1.2
2.1.0
2.0.10
2.0.9
2.0.8
2.0.7
2.0.6
2.0.5
2.0.1
2.0
1.9.1
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1.0
No labels
pull-request
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
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#1460
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @DjentAgent on GitHub (Sep 8, 2026).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/3146
Environment
7d4f3e0f5)Problem
AmneziaVPN randomly disconnects with Error 804 while connected through XRay.
The issue is not tied to high load, sleep/hibernate, screen off, or reconnecting.
It may happen after a short time or after a much longer session.
The actual failure is a crash of tun2socks.exe.
Crash #1
tun2socks reports:
fatal error: unexpected signal during runtime execution
[signal 0xc0000005 code=0x0 addr=0x1c00000020 ...]
Relevant stack:
sync/atomic.(*Pointer[...]).Load
sync.(*poolChain).popTail
sync.(*Pool).getSlow
sync.(*Pool).Get
go.uber.org/zap/internal/pool.(*Pool[...]).Get
go.uber.org/zap/zapcore.getCheckedEntry
...
github.com/xjasonlyu/tun2socks/v2/log.Infof
github.com/xjasonlyu/tun2socks/v2/tunnel.(*Tunnel).handleUDPConn
After that AmneziaVPN logs:
Tun2socks process was closed with 2 exit code
XrayProtocol::stop()
ErrorCode::804
Crash #2
A second crash happened on another session, again with:
signal 0xc0000005
addr=0x1c00000020
sync.(*poolChain).popTail
sync.(*Pool).Get
But this time the stack was different:
io.discard.ReadFrom
io.Copy
net.(*TCPConn).WriteTo
github.com/xjasonlyu/tun2socks/v2/proxy.(*Socks5).DialUDP.func2
Again, after the crash:
Tun2socks process was closed with 2 exit code
XrayProtocol::stop()
Error 804
This suggests the zap logger itself is probably not the root cause, because the second crash happened in a different code path, while the same sync.Pool / access violation pattern remained.
Additional notes
Expected behavior
The XRay connection should remain stable and tun2socks should not crash.
@DjentAgent commented on GitHub (Sep 8, 2026):
AmneziaVPN(1).log
AmneziaVPN.log
@HeisLuka commented on GitHub (Sep 8, 2026):
There is one packaging/build variable here that may be worth isolating before treating Error 804 as an XRay issue.
I checked the exact 5.0.1.5 source from the report. Amnezia builds:
tun2socks v2.6.0
with Go 1.26.0
However upstream tun2socks v2.6.0 itself declares:
go 1.23.1
gVisor 20250523...
zap 1.27.0
Upstream later explicitly migrated to Go 1.26 together with newer gVisor/dependencies, and current upstream v2.7.0 uses:
Go 1.26.3
gVisor 20260701...
zap 1.28.0
Current Amnezia dev still packages tun2socks/2.6.0.
I am not saying this proves a Go/toolchain incompatibility. But because the reported failures are Windows 0xc0000005 access violations inside Go runtime / sync.Pool, this gives a useful controlled build matrix.
I would reproduce the same UDP-heavy XRay workload with:
A. upstream v2.6.0 build / its original toolchain-compatible build
B. current Amnezia:
tun2socks v2.6.0 + Go 1.26.0
C. tun2socks v2.7.0 + current upstream Go/dependency set
Interpretation:
only B crashes
-> investigate Amnezia packaging/toolchain combination
A + B crash, C stable
-> likely v2.6/runtime dependency issue;
v2.7 becomes a strong upgrade candidate
A + B + C crash
-> reproduce/report upstream tun2socks/Go/gVisor Windows issue
only Amnezia-integrated runs crash
-> investigate process/TUN/IPC integration rather than tun2socks itself
This seems especially useful because the two crashes in the report do not share the same application stack frame:
crash 1: logging / handleUDPConn
crash 2: io.Copy / Socks5.DialUDP
while the low-level failure pattern is similar. That makes blaming zap from the first stack alone unsafe.
There is also a separate recovery question in Amnezia.
XrayProtocol::startTun2Socks() currently retries the known startup failure:
"resource busy"
but a runtime CrashExit is terminal:
tun2socks crash
-> stop()
-> ErrorCode::Tun2SockExecutableCrashed (804)
I would keep that separate from the root-cause experiment. Automatically restarting a process after a possible memory-corruption crash could hide the failure frequency.
If graceful recovery is later added, I would make it bounded and observable, e.g.:
first unexpected runtime crash
-> record crash signature + uptime
-> rebuild TUN/routing state cleanly
-> one controlled restart
repeated crash inside a short window
-> fail closed with 804
rather than an unlimited restart loop.
A useful regression/stress test would therefore record:
tun2socks build/version
Go version
runtime before crash
TCP/UDP flow counts
crash exit/status
automatic-recovery count
and run the same traffic profile for A/B/C.
That should tell us whether #3146 belongs primarily to Amnezia integration, the specific v2.6 build combination, or upstream tun2socks.
@C1nderC0ated commented on GitHub (Sep 22, 2026):
crashes for me too
@C1nderC0ated commented on GitHub (Sep 23, 2026):
Data point: matrix arm C (tun2socks v2.7.0 + current toolchain/deps) — ~7 h clean vs ~55 min MTBF on the bundled build
I ran @HeisLuka's arm C on one Windows machine. Single machine, so not conclusive, but here are the numbers.
Setup
xtls-rprx-vision) — note this is a different transport from the original report, which is XHTTPTun2socks process was closed with 2 exit codego version -mon the bundled binary matches arm B as described above. The main module shows as(devel); the dependency versions are exactly those in v2.6.0'sgo.mod:Baseline (arm B)
I had no tun2socks stderr captured, so I reconstructed process lifetimes from
Microsoft-Windows-NetworkProfile/Operationalevents 10000/10001 (tun2 adapter up/down):Caveat worth stating up front: those are lifetimes, not crash signatures. I cannot confirm my 804s carried the same
0xc0000005/sync.Poolstack as the report.Arm C
Built current upstream v2.7.0, unmodified except for the two integration patches below:
Dropped in as
tun2socks.exe(stock kept as a.bak).Result: 6 h 56 min continuous, 5,517,292 packets, 0 interface errors/discards, 0 process exits — with Discord voice (UDP, the path in crash #1) active for most of that window. Still no 804 the following day.
The caveat that matters: the toolchain and the dependency set moved together here, so this does not isolate go1.26.0 from gVisor/zap. It is arm C vs arm B, n=1 machine.
Arm A not obtained
I also tried the official upstream v2.6.0 release binary. Amnezia killed it ~10 s after start, 15/15 attempts, with no crash of its own. Flags and
[STACK]output were identical to the build that works, so I never found the reason. Arm A is effectively blocked for me.Two patches were needed before Amnezia would accept an upstream build
Relevant for anyone repeating this, and arguably worth fixing on one side or the other:
Flag style. Amnezia invokes tun2socks with single-dash long flags (
-device,-proxy,-loglevel, …). v2.6.0 uses the stdlibflagpackage, which accepts those; v2.7.0 switched tospf13/pflag, which reads-deviceas a cluster of shorthands and exits. I normalise argv (-name->--namefor the known long names) before pflag sees it.[STACK]readiness line. Amnezia waits for a specific shape of the[STACK]line on stderr. Upstream emitslog.Infof("[STACK] %s <-> %s", k.Device, k.Proxy); Amnezia expects[STACK] <type>://<name> <-> <scheme>://<host>. Separately, and independent of this issue: that line writes the full proxy URL including credentials into the log. Redacting it upstream looks worthwhile either way.Edit: corrected the build command (the main package is at the module root, not
./cmd/tun2socks) and thego version -mexcerpt.