<!-- XE-13314 · [net/gossip.go] H13: gossipHandler() tidak handle concurrent write ke shared state — race condition · testnet -->
*Markdown view of <https://bounty.xe.network/XE-13314>. The page is the record; this is the same page for reading.*

XE-13314 · Bounty

# \[net/gossip.go\] H13: gossipHandler() tidak handle concurrent write ke shared state — race condition

Closed · invalid
—
[xe#459](https://github.com/xeprotocol/xe/issues/459)
filed 2026-11-12 02:55 UTC
by wahyu20260100233-ops

Verdict
:   Invalid

Tier
:   —

Claimed
:   —

Area
:   P2P / sync

Duplicate of
:   —

Tracked
:   —

Updated
:   2026-11-20 00:51 UTC

Told
:   2026-11-20 00:50 UTC

### Patches

None linked.

### History

- [559434](https://bounty.xe.network/log/559434) 2026-11-20 00:50 UTC reply.mirrored
- [558492](https://bounty.xe.network/log/558492) 2026-11-20 00:49 UTC reply.sent
- [554093](https://bounty.xe.network/log/554093) 2026-11-20 00:36 UTC github.state\_pushed
- [554091](https://bounty.xe.network/log/554091) 2026-11-20 00:36 UTC github.labels
- [553369](https://bounty.xe.network/log/553369) 2026-11-20 00:33 UTC proposal.adopted
- [553190](https://bounty.xe.network/log/553190) 2026-11-20 00:33 UTC proposal.adopted
- [553189](https://bounty.xe.network/log/553189) 2026-11-20 00:33 UTC ticket.status new → closed
- [552856](https://bounty.xe.network/log/552856) 2026-11-20 00:33 UTC proposal.adopted
- [552855](https://bounty.xe.network/log/552855) 2026-11-20 00:33 UTC ticket.facts area
- [552850](https://bounty.xe.network/log/552850) 2026-11-20 00:33 UTC proposal.adopted
- [552849](https://bounty.xe.network/log/552849) 2026-11-20 00:33 UTC ticket.facts
- [550407](https://bounty.xe.network/log/550407) 2026-11-20 00:29 UTC note.added

[Full history](https://bounty.xe.network/log?ref=XE-13314) · [JSON](https://bounty.xe.network/v1/tickets/XE-13314) · [markdown](https://bounty.xe.network/XE-13314.md)

### Report

## Ringkasan

Kalau multiple stream handler dijalankan bersamaan dan modify shared state (misalnya `g.peers`), bisa terjadi race condition.

## Lokasi

- File: `net/gossip.go`
- Lines: 219-245

## Kode

```
func (g *Gossip) gossipHandler(stream network.Stream) {
    ...
    var msg GossipMessage
    if err := gob.NewDecoder(stream).Decode(&msg); err != nil {
        logging.Debugf("gossip: failed to decode message: %v", err)
        return
    }
    // handler modify shared state tanpa synchronization
    g.handleMessage(msg)
}
```

## Impact

Race condition kalau multiple handler modify shared state bersamaan.

## Suggested Fix

```
func (g *Gossip) gossipHandler(stream network.Stream) {
    ...
    var msg GossipMessage
    if err := gob.NewDecoder(stream).Decode(&msg); err != nil {
        logging.Debugf("gossip: failed to decode message: %v", err)
        return
    }

    // gunakan channel-based approach untuk menghindari race condition
    g.msgChan <- msg
}

func (g *Gossip) messageProcessor() {
    for msg := range g.msgChan {
        g.handleMessage(msg)
    }
}
```

### Thread

**XE desk**team2026-11-20 00:50 UTCgithub

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links
https://bounty.xe.network/XE-13314 and says what; it is read like any other.
