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 [*DeprecatedApiService] #2

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

Summary of Data Races associated with [*DeprecatedApiService] #2

dwymi02 opened this issue Sep 24, 2021 · 0 comments

Comments

@dwymi02
Copy link
Contributor

dwymi02 commented Sep 24, 2021

RE : DeprecatedApiService_Data_Races_Sep-21-2021.txt
Summary of Data Races associated with [*DeprecatedApiService]

  • 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 [*DeprecatedApiService]

  • DeprecatedApiService Data Race # 1:
    sync blocks from peer hacash_beijing(182.92.163.225:3337): 36001... got blocks: 36001 ~ 37000, inserting... OK
    sync blocks from peer hacash_beijing(182.92.163.225:3337): 37001... got blocks: 37001 ~ 38000, inserting... ==================
    WARNING: DATA RACE
    Read at 0x00c420194f30 by goroutine 57:
    service/deprecated.(*DeprecatedApiService).dealHome()
    service/deprecated/home.go:131 +0x1851
    service/deprecated.(*DeprecatedApiService).(service/deprecated.dealHome)-fm()
    service/deprecated/http.go:82 +0x5f
    net/http.HandlerFunc.ServeHTTP()
    /opt/go/src/net/http/server.go:1947 +0x51
    net/http.(*ServeMux).ServeHTTP()
    /opt/go/src/net/http/server.go:2340 +0x9f
    net/http.serverHandler.ServeHTTP()
    /opt/go/src/net/http/server.go:2697 +0xb9
    net/http.(*conn).serve()
    /opt/go/src/net/http/server.go:1830 +0x7dc

    Previous write at 0x00c420194f30 by goroutine 40:
    miner/memtxpool.(*TxGroup).Clean()
    miner/memtxpool/group.go:36 +0x7f
    miner/memtxpool.(*MemTxPool).loop()
    miner/memtxpool/loop.go:18 +0x336

    Read:
    [service/deprecated/home.go:131]
    [service/deprecated.(*DeprecatedApiService).dealHome()]
    ...
    ...
    ...
    // 交易池信息
    txpool := api.txpool
    if pool, ok := txpool.(*memtxpool.MemTxPool); ok {
    diamonds := ""
    hd := pool.GetDiamondCreateTxGroup().Head
    for i := 0; i < 200; i++ {
    if hd != nil {
    if as := hd.GetTx().GetActions(); len(as) > 0 {
    if as[0].Kind() == 4 {
    if dia, ok := as[0].(*actions.Action_4_DiamondCreate); ok {
    if len(diamonds) > 0 { <=== Read
    diamonds += " / " + string(dia.Diamond)
    } else {
    diamonds = string(dia.Diamond)
    }
    }
    }
    }
    hd = hd.GetNext()
    } else {
    break
    }
    }
    plcount, plsize := pool.GetTotalCount()
    responseStrAry = append(responseStrAry, fmt.Sprintf(
    "txpool length: %d, size: %fkb, diamond: %s",
    plcount,
    float64(plsize)/1024,
    diamonds,
    ))
    }
    ...
    ...
    ...

    Write:
    [miner/memtxpool/group.go:36]
    func (g *TxGroup) Clean() {
    g.itemsLocker.Lock()
    defer g.itemsLocker.Unlock()

    g.Head = nil <== Write
    g.Tail = nil
    g.items = make(map[string]*TxItem)
    g.Count = 0
    }

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

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