Skip to content

Race condition in muxer if connection is closed immediately after handshake #710

@agaffney

Description

@agaffney

When a connection is closed almost immediately after a successful handshake, the muxer shutdown can trigger while protocols are still being registered, causing the m.waitGroup.Wait() to start before all of the m.waitGroup.Add() calls have completed, which causes a panic.

panic: sync: WaitGroup is reused before previous Wait has returned

goroutine 3362 [running]:
sync.(*WaitGroup).Wait(0xc000b5ef78?
)
    /opt/hostedtoolcache/go/1.21.13/x64/src/sync/waitgroup.go:118 +0x74
github.com/blinklabs-io/gouroboros/muxer.New.func1()
    /home/runner/go/pkg/mod/github.com/blinklabs-io/[email protected]/muxer/muxer.go:92 +0x48
created by github.com/blinklabs-io/gouroboros/muxer.New in goroutine 52
    /home/runner/go/pkg/mod/github.com/blinklabs-io/[email protected]/muxer/muxer.go:85 +0x198

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions