Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace: protect field access with lock to avoid possible data race #926

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

trace: protect field access with lock to avoid possible data race #926

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

Comments

@yanke-xu
Copy link

Fixed inconsistency and also potential data race in trace/events.go:
el.discarded is read/written 5 times in trace/events.go; 4 out of 5 times it is protected by el.mu.Lock(); 1 out of 5 times it is write without a Lock, which is in func reset() on L280.
A data race may happen when reset() and other func like Stop() which cotains operation about el.discarded are called in parallel.

In order to avoid potential data race here, I use el.mu.Lock(); defer el.mu.Unlock() to make sure that all usages of items is in critical section.

I don't know whether it is accurate, so I 'm looking forward to your reply.

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

No branches or pull requests

1 participant