Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

proto: protect field access with proto to avoid possible data race #3986

Open
yanke-xu opened this issue Mar 7, 2023 · 0 comments
Open

proto: protect field access with proto to avoid possible data race #3986

yanke-xu opened this issue Mar 7, 2023 · 0 comments

Comments

@yanke-xu
Copy link

yanke-xu commented Mar 7, 2023

Fixed inconsistency and also potential data race in weave/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go:
u.reqFields is read/written 4 times in weave/vendor/github.com/gogo/protobuf/proto/table_unmarshal.go; 3 out of 4 times it is protected by u.lock; 1 out of 4 times it is read without a Lock, which is in func unmarshal() on L260.
A data race may happen when unmarshal() and other func computeUnmarshalInfo() are called in parallel.

In order to avoid potential data race here, I use u.lock.RLock(); defer u.lock.RUnlock() to make sure that all usages of items is in critical section.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant