From a45bc8aa5a752c266b9e15d2605680f888ede054 Mon Sep 17 00:00:00 2001 From: kari-ts Date: Mon, 16 Jun 2025 11:16:31 -0700 Subject: [PATCH] ipn/ipnlocal: fix nil bus panic Android was hitting a panic due to the event bus not being set when creating a new local backend. This adds a nil check and fallback if the eventbus has not been initiated. Updates #cleanup Signed-off-by: kari-ts --- ipn/ipnlocal/local.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ipn/ipnlocal/local.go b/ipn/ipnlocal/local.go index cd30e92bb..1f73c5d31 100644 --- a/ipn/ipnlocal/local.go +++ b/ipn/ipnlocal/local.go @@ -515,7 +515,16 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo captiveCancel: nil, // so that we start checkCaptivePortalLoop when Running needsCaptiveDetection: make(chan bool), } - nb := newNodeBackend(ctx, b.sys.Bus.Get()) + var bus *eventbus.Bus + if b.sys != nil { + bus = b.sys.Bus.Get() + } + if bus == nil { + log.Printf("WARNING: sys.Bus is not set; using fallback bus.") + bus = eventbus.New() + } + nb := newNodeBackend(ctx, bus) + b.currentNodeAtomic.Store(nb) nb.ready()