From 604c391b74d6f448bf17ae9b368abffe7e5bc319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=C3=B3rio=20G=2E?= Date: Wed, 25 Sep 2024 09:22:05 -0300 Subject: [PATCH] fix(proctree): possible sync.Once data race (#4307) --- pkg/proctree/proctree.go | 1 + pkg/proctree/proctree_procfs.go | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/proctree/proctree.go b/pkg/proctree/proctree.go index ef0104848d75..aac3a2ba4a48 100644 --- a/pkg/proctree/proctree.go +++ b/pkg/proctree/proctree.go @@ -143,6 +143,7 @@ func NewProcessTree(ctx context.Context, config ProcTreeConfig) (*ProcessTree, e procTree := &ProcessTree{ processes: processes, threads: threads, + procfsOnce: new(sync.Once), ctx: ctx, procfsQuery: config.ProcfsQuerying, } diff --git a/pkg/proctree/proctree_procfs.go b/pkg/proctree/proctree_procfs.go index 8d25885b0379..bf77ab73609c 100644 --- a/pkg/proctree/proctree_procfs.go +++ b/pkg/proctree/proctree_procfs.go @@ -46,9 +46,6 @@ func (pt *ProcessTree) FeedFromProcFSAsync(givenPid int) { pt.procfsChan = make(chan int, 1000) pt.feedFromProcFSLoop() } - if pt.procfsOnce == nil { - pt.procfsOnce = new(sync.Once) - } // feed the loop without blocking (if the loop is busy, given pid won't be processed) select {