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

CListMempool has data race(s) #642

Closed
peterbourgon opened this issue Apr 3, 2023 · 1 comment · Fixed by #2021
Closed

CListMempool has data race(s) #642

peterbourgon opened this issue Apr 3, 2023 · 1 comment · Fixed by #2021
Assignees
Labels
bug Something isn't working mempool
Milestone

Comments

@peterbourgon
Copy link

mempool.CListMempool.Update writes to the height field under the assumption that the updateMtx field on the CListMempool struct has been locked by its caller. But e.g. mempool.CListMempool.resCbFirstTime reads from the height field without taking that lock. And that method is called by reqResCb via abci/client.ReqRes.SetCallback, neither of which take the lock. This is a data race.

The height field (and others) are commented as "atomic" which suggests they are expected to be accessed with sync/atomic functions like mempoolTx.Height. But that's not the case at the moment. If that's the intent, then they should only be accessed with sync/atomic functions, and do not require the updateMtx to be locked. But this kind of mixing of individually-atomic fields and a mutex that governs (apparently arbitrary) fields in the type is basically impossible to get right :) and probably deserves a refactor.

@peterbourgon peterbourgon added bug Something isn't working needs-triage This issue/PR has not yet been triaged by the team. labels Apr 3, 2023
@hvanz hvanz self-assigned this Apr 18, 2023
@hvanz hvanz added mempool and removed needs-triage This issue/PR has not yet been triaged by the team. labels Apr 18, 2023
@adizere adizere added this to the 2024-Q1 milestone Jan 11, 2024
github-merge-queue bot pushed a commit that referenced this issue Jan 12, 2024
…able (#2021)

Addresses #642

---

#### PR checklist

- [X] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
mergify bot pushed a commit that referenced this issue Jan 12, 2024
…able (#2021)

Addresses #642

---

#### PR checklist

- [X] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

(cherry picked from commit ce6d2fb)

# Conflicts:
#	mempool/clist_mempool_test.go
mergify bot pushed a commit that referenced this issue Jan 12, 2024
…able (#2021)

Addresses #642

---

#### PR checklist

- [X] Tests written/updated
- [x] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments

(cherry picked from commit ce6d2fb)

# Conflicts:
#	mempool/clist_mempool.go
#	mempool/clist_mempool_test.go
@adizere
Copy link
Member

adizere commented Jan 15, 2024

Closed by #2021

@adizere adizere closed this as completed Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working mempool
Projects
Status: Done
Status: Todo
Development

Successfully merging a pull request may close this issue.

3 participants