Skip to content

fix: join node thread on stop; skip Phy close handlers in dtor - #294

Open
brukberhane wants to merge 1 commit into
zerotier:mainfrom
brukberhane:pr/node-stop-join
Open

brukberhane wants to merge 1 commit into
zerotier:mainfrom
brukberhane:pr/node-stop-join

Conversation

@brukberhane

Copy link
Copy Markdown

Summary

  • zts_node_stop / zts_node_free returned before _runNodeService finished delete zts_service, so a second ZeroTier node (Android VPN JNI) could start while libzt was still tearing down the same identity.
  • ~Phy() called close(..., true)phyOnTcpClose after NodeService members such as _tcpConnections_m were already destroyed → FORTIFY pthread_mutex_lock called on a destroyed mutex (SIGABRT on PROXY→VPN).

Changes

  • Store the service pthread_t and pthread_join it after terminate() (lock dropped first so the service thread can take service_m).
  • Carry a one-line ZeroTierOne patch (~Phy uses callHandlers=false) applied from build.sh, because that destructor lives in the nested submodule.

Seen in ZerotierB exclusive stack swap: libzt PROXY → JNI VPN.

Test plan

  • zts_node_start → traffic → zts_node_stopzts_node_start without SIGABRT
  • Android: PROXY mode up, switch to VPN; no crash in libzt-node / _runNodeService
  • ./build.sh android-aar release applies patches/zerotierone/0001-phy-dtor-skip-close-handlers.patch on a clean ZeroTierOne checkout

Made with Cursor

zts_node_stop returned before _runNodeService deleted NodeService.
~Phy then called phyOnTcpClose after _tcpConnections_m was destroyed
(FORTIFY SIGABRT on PROXY→VPN). Join the service pthread; close
leftover sockets without handlers via a ZeroTierOne patch.

Co-authored-by: Cursor <cursoragent@cursor.com>
@CLAassistant

CLAassistant commented Aug 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants