XE-13297 · Bounty
[net/sync.go] M11: syncPeer() tidak handle error dari dialStreams — goroutine leak
Report
Ringkasan
Kalau dialStreams gagal, error hanya di-log. Tidak ada cleanup. Kalau error terjadi berulang, goroutine yang di-spawn bisa menumpuk.
Lokasi
- File:
net/sync.go - Lines: 248-274
Kode
func (t *tracker) syncPeer(ctx context.Context, h host.Host, pid peer.ID, opts ...SyncOption) error {
...
if err := t.dialStreams(ctx, h, pid, opts...); err != nil {
logging.Warnf("sync: failed to dial streams to %s: %v", pid, err)
return err
}
...
}
Impact
Goroutine leak kalau dialStreams gagal berulang. Resource exhaustion.
Suggested Fix
func (t *tracker) syncPeer(ctx context.Context, h host.Host, pid peer.ID, opts ...SyncOption) error {
...
if err := t.dialStreams(ctx, h, pid, opts...); err != nil {
logging.Warnf("sync: failed to dial streams to %s: %v", pid, err)
t.mu.Lock()
t.syncIncapable[pid] = struct{}{}
t.mu.Unlock()
return err
}
...
}
Atau tambah retry dengan backoff:
func (t *tracker) syncPeer(ctx context.Context, h host.Host, pid peer.ID, opts ...SyncOption) error {
...
var lastErr error
for i := 0; i < 3; i++ {
if err := t.dialStreams(ctx, h, pid, opts...); err != nil {
lastErr = err
logging.Warnf("sync: failed to dial streams to %s (attempt %d): %v", pid, i+1, err)
time.Sleep(time.Second * time.Duration(i+1))
continue
}
return nil
}
return lastErr
}
Thread
XE deskteam2026-11-20 00:49 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-13297 and says what; it is read like any other.