From 2df47c918bffd71e263058b49302bc7970bf0684 Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Mon, 9 Sep 2019 16:52:28 -0700 Subject: [PATCH] internal/impl: fix race ExtensionInfo.lazyInitSlow The xi.init flag should not be set until after we have truly initialized everything. Change-Id: I43dcb300917145ce19a7199fa871acd0df325c6c Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194439 Reviewed-by: Damien Neil --- internal/impl/extension.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/impl/extension.go b/internal/impl/extension.go index c64f8f5e..40074fc4 100644 --- a/internal/impl/extension.go +++ b/internal/impl/extension.go @@ -145,7 +145,7 @@ func (xi *ExtensionInfo) lazyInitSlow() { if xi.init == extensionInfoFullInit { return } - atomic.StoreUint32(&xi.init, extensionInfoFullInit) + defer atomic.StoreUint32(&xi.init, extensionInfoFullInit) if xi.desc == nil { xi.initFromLegacy()