Race in dbus
I seem to be able to trigger this fairly reliably. It pops up in two different ways, both are listed here.
I will admit that the code I wrote which uses this is very old and ugly, but a cursory look leads me to believe it's likely a bug in this library.
If you'd like more information, please let me know. FIgured I'd post this in case it's an obvious fix for the maintainers.
I'm happy to share code to reproduce it, but it's quite involved because https://github.com/purpleidea/mgmt/ which consumes this is not exactly small, so hopefully the trace is helpful.
Thanks!
==================
WARNING: DATA RACE
Read at 0x00c00235dc50 by goroutine 645:
runtime.mapaccess2_faststr()
/usr/lib/golang/src/internal/runtime/maps/runtime_faststr_swiss.go:162 +0x0
github.com/coreos/go-systemd/v22/dbus.(*set).Contains()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/set.go:30 +0x68
github.com/coreos/go-systemd/v22/dbus.(*SubscriptionSet).filter()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription_set.go:29 +0x2b
github.com/coreos/go-systemd/v22/dbus.(*SubscriptionSet).Subscribe.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription_set.go:38 +0xe
github.com/coreos/go-systemd/v22/dbus.(*Conn).SubscribeUnitsCustom.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription.go:119 +0x318
github.com/coreos/go-systemd/v22/dbus.(*Conn).ListUnits()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/methods.go:452 +0xd3
github.com/coreos/go-systemd/v22/dbus.(*Conn).SubscribeUnitsCustom.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription.go:115 +0x9f
Previous write at 0x00c00235dc50 by goroutine 421:
runtime.mapassign_faststr()
/usr/lib/golang/src/internal/runtime/maps/runtime_faststr_swiss.go:263 +0x0
github.com/coreos/go-systemd/v22/dbus.(*set).Add()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/set.go:22 +0xc7b
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:242 +0xc31
github.com/coreos/go-systemd/v22/dbus.(*Conn).GetUnitPropertyContext()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/methods.go:333 +0x93c
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:204 +0x8ef
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:175 +0x2e2
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:101 +0x9e7
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:97 +0x9d1
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:200 +0xb5c
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:133 +0x67
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/purpleidea/mgmt/util.SystemBusPrivateUsable()
/home/james/code/mgmt/util/util.go:632 +0x44
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:167 +0x1a7
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/coreos/go-systemd/v22/dbus.dbusAuthConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:242 +0x1b6
github.com/coreos/go-systemd/v22/dbus.dbusAuthHelloConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:252 +0x3e
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:139 +0x44
github.com/coreos/go-systemd/v22/dbus.NewConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:196 +0x5a
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:200 +0xb5c
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:133 +0x67
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/coreos/go-systemd/v22/dbus.dbusAuthConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:242 +0x1b6
github.com/coreos/go-systemd/v22/dbus.dbusAuthHelloConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:252 +0x3e
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:139 +0x44
github.com/coreos/go-systemd/v22/dbus.NewConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:191 +0x3b
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:138 +0x72
github.com/coreos/go-systemd/v22/dbus.NewWithContext()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:123 +0x34
github.com/coreos/go-systemd/v22/dbus.New()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:117 +0xd3
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:156 +0xb7
github.com/purpleidea/mgmt/engine/graph.(*Engine).Worker.func1()
/home/james/code/mgmt/engine/graph/actions.go:521 +0x7da
Goroutine 645 (running) created at:
github.com/coreos/go-systemd/v22/dbus.(*Conn).SubscribeUnitsCustom()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription.go:111 +0x27c
github.com/coreos/go-systemd/v22/dbus.(*SubscriptionSet).Subscribe()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription_set.go:36 +0xb1
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:191 +0x88a
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:175 +0x2e2
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:101 +0x9e7
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:97 +0x9d1
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:200 +0xb5c
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:133 +0x67
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/purpleidea/mgmt/util.SystemBusPrivateUsable()
/home/james/code/mgmt/util/util.go:632 +0x44
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:167 +0x1a7
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/coreos/go-systemd/v22/dbus.dbusAuthConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:242 +0x1b6
github.com/coreos/go-systemd/v22/dbus.dbusAuthHelloConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:252 +0x3e
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:139 +0x44
github.com/coreos/go-systemd/v22/dbus.NewConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:196 +0x5a
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:200 +0xb5c
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:133 +0x67
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/coreos/go-systemd/v22/dbus.dbusAuthConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:242 +0x1b6
github.com/coreos/go-systemd/v22/dbus.dbusAuthHelloConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:252 +0x3e
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:139 +0x44
github.com/coreos/go-systemd/v22/dbus.NewConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:191 +0x3b
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:138 +0x72
github.com/coreos/go-systemd/v22/dbus.NewWithContext()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:123 +0x34
github.com/coreos/go-systemd/v22/dbus.New()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:117 +0xd3
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:156 +0xb7
github.com/purpleidea/mgmt/engine/graph.(*Engine).Worker.func1()
/home/james/code/mgmt/engine/graph/actions.go:521 +0x7da
Goroutine 421 (running) created at:
github.com/purpleidea/mgmt/engine/graph.(*Engine).Worker()
/home/james/code/mgmt/engine/graph/actions.go:450 +0xa24
github.com/purpleidea/mgmt/engine/graph.(*Engine).Commit.func1.2.1()
/home/james/code/mgmt/engine/graph/engine.go:310 +0x2ba
github.com/purpleidea/mgmt/engine/graph.(*Engine).Commit.func1.2.gowrap1()
/home/james/code/mgmt/engine/graph/engine.go:325 +0x4f
==================
==================
WARNING: DATA RACE
Read at 0x00c000af8288 by goroutine 645:
github.com/coreos/go-systemd/v22/dbus.(*set).Contains()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/set.go:30 +0x71
github.com/coreos/go-systemd/v22/dbus.(*SubscriptionSet).filter()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription_set.go:29 +0x2b
github.com/coreos/go-systemd/v22/dbus.(*SubscriptionSet).Subscribe.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription_set.go:38 +0xe
github.com/coreos/go-systemd/v22/dbus.(*Conn).SubscribeUnitsCustom.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription.go:119 +0x318
github.com/coreos/go-systemd/v22/dbus.(*Conn).ListUnits()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/methods.go:452 +0xd3
github.com/coreos/go-systemd/v22/dbus.(*Conn).SubscribeUnitsCustom.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription.go:115 +0x9f
Previous write at 0x00c000af8288 by goroutine 421:
github.com/coreos/go-systemd/v22/dbus.(*set).Add()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/set.go:22 +0xc8a
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:242 +0xc31
github.com/coreos/go-systemd/v22/dbus.(*Conn).GetUnitPropertyContext()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/methods.go:333 +0x93c
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:204 +0x8ef
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:175 +0x2e2
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:101 +0x9e7
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:97 +0x9d1
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:200 +0xb5c
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:133 +0x67
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/purpleidea/mgmt/util.SystemBusPrivateUsable()
/home/james/code/mgmt/util/util.go:632 +0x44
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:167 +0x1a7
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/coreos/go-systemd/v22/dbus.dbusAuthConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:242 +0x1b6
github.com/coreos/go-systemd/v22/dbus.dbusAuthHelloConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:252 +0x3e
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:139 +0x44
github.com/coreos/go-systemd/v22/dbus.NewConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:196 +0x5a
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:200 +0xb5c
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:133 +0x67
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/coreos/go-systemd/v22/dbus.dbusAuthConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:242 +0x1b6
github.com/coreos/go-systemd/v22/dbus.dbusAuthHelloConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:252 +0x3e
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:139 +0x44
github.com/coreos/go-systemd/v22/dbus.NewConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:191 +0x3b
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:138 +0x72
github.com/coreos/go-systemd/v22/dbus.NewWithContext()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:123 +0x34
github.com/coreos/go-systemd/v22/dbus.New()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:117 +0xd3
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:156 +0xb7
github.com/purpleidea/mgmt/engine/graph.(*Engine).Worker.func1()
/home/james/code/mgmt/engine/graph/actions.go:521 +0x7da
Goroutine 645 (running) created at:
github.com/coreos/go-systemd/v22/dbus.(*Conn).SubscribeUnitsCustom()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription.go:111 +0x27c
github.com/coreos/go-systemd/v22/dbus.(*SubscriptionSet).Subscribe()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/subscription_set.go:36 +0xb1
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:191 +0x88a
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:175 +0x2e2
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:101 +0x9e7
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:97 +0x9d1
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:200 +0xb5c
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:133 +0x67
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/purpleidea/mgmt/util.SystemBusPrivateUsable()
/home/james/code/mgmt/util/util.go:632 +0x44
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:167 +0x1a7
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/coreos/go-systemd/v22/dbus.dbusAuthConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:242 +0x1b6
github.com/coreos/go-systemd/v22/dbus.dbusAuthHelloConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:252 +0x3e
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:139 +0x44
github.com/coreos/go-systemd/v22/dbus.NewConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:196 +0x5a
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:200 +0xb5c
github.com/godbus/dbus/v5.(*Conn).tryAuth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:133 +0x67
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:86 +0x919
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:80 +0x8ad
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:68 +0x47c
github.com/godbus/dbus/v5.(*Conn).Auth()
/home/james/code/gopath/pkg/mod/github.com/godbus/dbus/[email protected]/auth.go:64 +0x466
github.com/coreos/go-systemd/v22/dbus.dbusAuthConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:242 +0x1b6
github.com/coreos/go-systemd/v22/dbus.dbusAuthHelloConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:252 +0x3e
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext.func1()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:139 +0x44
github.com/coreos/go-systemd/v22/dbus.NewConnection()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:191 +0x3b
github.com/coreos/go-systemd/v22/dbus.NewSystemConnectionContext()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:138 +0x72
github.com/coreos/go-systemd/v22/dbus.NewWithContext()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:123 +0x34
github.com/coreos/go-systemd/v22/dbus.New()
/home/james/code/gopath/pkg/mod/github.com/coreos/go-systemd/[email protected]/dbus/dbus.go:117 +0xd3
github.com/purpleidea/mgmt/engine/resources.(*SvcRes).Watch()
/home/james/code/mgmt/engine/resources/svc.go:156 +0xb7
github.com/purpleidea/mgmt/engine/graph.(*Engine).Worker.func1()
/home/james/code/mgmt/engine/graph/actions.go:521 +0x7da
Goroutine 421 (running) created at:
github.com/purpleidea/mgmt/engine/graph.(*Engine).Worker()
/home/james/code/mgmt/engine/graph/actions.go:450 +0xa24
github.com/purpleidea/mgmt/engine/graph.(*Engine).Commit.func1.2.1()
/home/james/code/mgmt/engine/graph/engine.go:310 +0x2ba
github.com/purpleidea/mgmt/engine/graph.(*Engine).Commit.func1.2.gowrap1()
/home/james/code/mgmt/engine/graph/engine.go:325 +0x4f
==================
Are you modifying the SubscriptionSet after you called Subscribe() on it?
Subscribe() spawns a gorouting which will read from the set (map) so adding new things afterwards is no longer safe. It should be possible to add a mutex to the map to prevent concurrent access here in theory if modifying it is a valid use case.
What I find worse however is that Subscribe() calls SubscribeUnitsCustom() which spawns the goroutine with no way to cancel it. So I am not sure this is a particular a sane API I would recommend to be used. cc @kolyshkin
Are you modifying the SubscriptionSet after you called Subscribe() on it?
Indeed I am.
Now to be perfectly fair, as I mentioned, this is in some old ugly code, which is assuredly not optimal, but at the bare minimum this should be either documented as being not thread safe, or fixed I think.
If you believe this is crazy behaviour on my part to even hit this, then I will accept that as an answer, and look into rewriting my code before I persist here.
Anything else you need, please let me know. Thank you!
I'm having a deeper look at this. AFAICT (If I'm groking the API properly) this is confirmed from my POV as a bug...
I imagine the way I envisioned this is that you build a subscription set, and periodically you change what you're interested in... So I'd expect it to be thread safe and dynamically adjusting to what we're requesting.
Otherwise I assume you'd have to do some weird hacky stuff where you start a new subscription, and only after you know it's ready (how???) do you then kill off the other one?
HTH
only after you know it's ready (how???) do you then kill off the other one?
Like I mentioned there is no way, each Subscribe() leaks one goroutine.
so yeah sure adding a mutex here does make sense if there are users who have to update the set, PRs welcome.
But really the fact that this cannot be cancelled using a context is just a broken API. At the very least the function comments must be updated to warn of this issue. Or better we deprecate that function and add a SubscribeContext alternative which can be cancelled.
@purpleidea I believe my PR should fix your issue @kolyshkin I need this very exact function for my project as well, could you review the fix?