Skip to content

Conversation

@vecljox
Copy link
Contributor

@vecljox vecljox commented Sep 24, 2025

On Android, when calling start() and stop() multiple times in a VPN application using tun2socks, the program crashes with:

fdsan: attempted to close file descriptor XXX, expected to be unowned, actually owned by unique_fd ...

This happens because both _defaultDevice.Close() and _defaultStack.Wait(), which are called inside stop(), attempt to close the same file descriptor. The issue was observed when using ParcelFileDescriptor from VpnService, where the FD is detached and passed to the tun2socks engine.

@xjasonlyu xjasonlyu added the bug Something isn't working label Oct 8, 2025
@xjasonlyu xjasonlyu force-pushed the fix/stop-fd-double-close branch from c61a96a to 8ce1a2c Compare October 8, 2025 12:13
@xjasonlyu xjasonlyu merged commit 8fe7561 into xjasonlyu:main Oct 8, 2025
4 checks passed
@xjasonlyu
Copy link
Owner

LGTM, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants