Skip to content

CListMempool has data race(s) #642

Closed

Description

@peterbourgon

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.

Activity

  1. added
    bug
    needs-triage
    on Apr 3, 2023
  2. self-assigned this
    on Apr 18, 2023
  3. removed
    needs-triage
    on Apr 18, 2023
  4. added this to the 2024-Q1 milestone on Jan 11, 2024
  5. moved this from Todo to Done in CometBFTon Jan 15, 2024
  6. adizere commented on Jan 15, 2024

    @adizere
    Contributor

    Closed by #2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugmempool

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions