From 6b25eb2e79954807031964062777f1755aadee82 Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Mon, 22 Mar 2021 15:07:41 +0100 Subject: [PATCH] lib/ur: Prevent panic when blocksResult is nil (ref #7495) (#7515) --- lib/ur/usage_report.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ur/usage_report.go b/lib/ur/usage_report.go index 35b8fc1ad..d477d6a86 100644 --- a/lib/ur/usage_report.go +++ b/lib/ur/usage_report.go @@ -426,12 +426,12 @@ func CpuBench(ctx context.Context, iterations int, duration time.Duration, useWe perf = v } } - if blocksResult == nil { - // not looking at the blocksResult makes it unused from a static - // analysis / compiler standpoint... - panic("blocksResult should have been set by benchmark loop") + // not looking at the blocksResult makes it unused from a static + // analysis / compiler standpoint... + // blocksResult may be nil at this point if the context is cancelled + if blocksResult != nil { + blocksResult = nil } - blocksResult = nil return perf }