From 236c32faaef726f5c53af5d57a2c84fe02393104 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 19 Aug 2019 15:20:42 +0200 Subject: manager: do not recycle tunnel tracker thread --- manager/tunneltracker.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/manager/tunneltracker.go b/manager/tunneltracker.go index 32605b36..72942036 100644 --- a/manager/tunneltracker.go +++ b/manager/tunneltracker.go @@ -125,7 +125,15 @@ func trackTunnelService(tunnelName string, service *mgr.Service) { } runtime.LockOSThread() - defer runtime.UnlockOSThread() + + // This line would be fitting but is intentionally commented out: + // + // defer runtime.UnlockOSThread() + // + // The reason is that NotifyServiceStatusChange used queued APC, which winds up messing + // with the thread local context, which in turn appears to corrupt Go's own usage of TLS, + // leading to crashes sometime later (usually in runtime_unlock()) when the thread is recycled. + lastState := TunnelUnknown for { err := windows.NotifyServiceStatusChange(service.Handle, serviceNotifications, notifier) -- cgit v1.2.3-59-g8ed1b