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

Summary of Data Races associated with [*Block_v1] #3

Open
dwymi02 opened this issue Sep 23, 2021 · 0 comments
Open

Summary of Data Races associated with [*Block_v1] #3

dwymi02 opened this issue Sep 23, 2021 · 0 comments

Comments

@dwymi02
Copy link
Contributor

dwymi02 commented Sep 23, 2021

Summary of Data Races associated with [*Block_v1]

  • Text file of instrumented Diamond Miner [DiamondMiner_log_Sep_21_2021.txt], available via Github Gist [https://gist.github.com/dwymi02/95140687b566efa22939dec3cd14dd6d]

  • The instrumented binary was built from refreshed code, dated Sep-21-2021.
    The source code repository was wiped clean and "git clone ..." was used to create the updated code base.

  • The instrumented code was built with "-race", e.g., "go build -race".

  • The directory [hacash_mainnet_data/] was completely removed, to allow the Hacash blockchain to be built from scratch, also allowing for additional Data Races to be uncovered, if any.

  • In searching for Data Races I tried to group them based on specific Hacash components.
    Grep was used to search for known Hacash components, following is a list of potential Data Races, based on Hacash components:

    • A search for [*P2P] returned 109 hits
    • A search for [*Block_v1] returned 4 hits
    • A search for [*ChainState] returned 3 hits
    • A search for [*DiamondMiner] returned 45 hits
    • A search for [*DeprecatedApiService] returned 33 hits
    • A search for [*Transaction_2_Simple] returned 14 hits
      While there are large numbers of potential hits, there Hacash components may or may not be proximate to the actual Data Race.

    For each Hacash component I will list the specific Data Race.
    When the current code does not match what was previously built, a [*** NOTE ***] will be included
    In the event the stack trace that is too lengthy, the results will be truncated.
    If it is necessary, the full log will be provided, as needed.

    For the specific Read and Write that are involved in the Data Race, the [<===] will be used to identify where the specific Read/Write occurred, based on current source available ...

    Once the Data Race has been documented, an issue will be opened on Github.
    I will leave it to your team to decide how the Data Race is to be handled.
    You can opt to fix the Data Race or simply close the issue. as you so choose.
    This decision I leave with you and your team ...

=-=-=-=-=-=-=-=-=-=-=-=-=-

Data Races associated with [*Block_v1]

  • Block_v1 Data Race # 1:
    sync blocks from peer hacash_beijing(182.92.163.225:3337): 3001... [P2P] find 8 nearest public nodes to update topology table, connected peers: 5 public, 0 private, total: 5 nodes, 5 conns.
    got blocks: 3001 ~ 4000, inserting... OK
    sync blocks from peer hacash_beijing(182.92.163.225:3337): 4001... got blocks: 4001 ~ 5000, inserting... ==================
    WARNING: DATA RACE
    Write at 0x00c420d4e748 by goroutine 122:
    core/blocks.(*Block_v1).HashFresh()
    core/blocks/version1.go:341 +0x7d
    mint/blockchain.(*BlockChain).tryValidateAppendNewBlockToChainStateAndStore()
    mint/blockchain/append.go:50 +0x3c5
    mint/blockchain.(*BlockChain).InsertBlock()
    mint/blockchain/append.go:27 +0x5a
    node/handler.GetBlocksData()
    node/handler/blockdata.go:43 +0x5ad
    node/backend.(*Backend).OnMsgData()
    node/backend/message.go:62 +0x342
    node/p2pv2.(*P2P).handleConnMsg()
    node/p2pv2/tcp_msg_handler.go:39 +0x8f5

    Previous read at 0x00c420d4e748 by goroutine 123:
    core/blocks.(*Block_v1).Hash()
    core/blocks/version1.go:335 +0x9c
    node/handler.SendStatusToPeer()
    node/handler/status.go:82 +0x105
    node/backend.(*Backend).OnMsgData()
    node/backend/message.go:37 +0x58c
    node/p2pv2.(*P2P).handleConnMsg()
    node/p2pv2/tcp_msg_handler.go:39 +0x8f5

    Write:
    [core/blocks/version1.go:341]
    [*** NOTE ***] The reported Data Race does not match the reported line ...
    func (block *Block_v1) hashFreshUnsafe() fields.Hash {
    block.hash = CalculateBlockHash(block) <=== Actual Write
    return block.hash <=== Reported Write
    }

    Read:
    [core/blocks/version1.go:335]
    [*** NOTE ***] The reported Data Race does not match the reported line ...
    func (block *Block_v1) HashFresh() fields.Hash {
    block.insertLock.Lock()
    defer block.insertLock.Unlock()
    <=== Reported Read
    return block.hashFreshUnsafe()
    }

=-=-=-=-=-=-=-=-=-=-=-=-=-

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