Skip to content

client: corebgp logging is not thread safe #296

@packethog

Description

@packethog

The logger is a package-level var so if there are multiple servers running in the same process, this can be racey:

https://github.com/jwhited/corebgp/blob/v0.8.5/logger.go#L14-L17

WARNING: DATA RACE
Read at 0x0000011bb370 by goroutine 75:
  github.com/jwhited/corebgp.log()
      /go/pkg/mod/github.com/jwhited/corebgp@v0.8.5/logger.go:20 +0xc0
  github.com/jwhited/corebgp.logf()
      /go/pkg/mod/github.com/jwhited/corebgp@v0.8.5/logger.go:26 +0x34
  github.com/jwhited/corebgp.(*peer).logTransition()
      /go/pkg/mod/github.com/jwhited/corebgp@v0.8.5/peer.go:92 +0x134
  github.com/jwhited/corebgp.(*peer).sendTransitionToFSM()
      /go/pkg/mod/github.com/jwhited/corebgp@v0.8.5/peer.go:111 +0xec
  github.com/jwhited/corebgp.(*peer).handleStateTransition()
      /go/pkg/mod/github.com/jwhited/corebgp@v0.8.5/peer.go:196 +0x338
  github.com/jwhited/corebgp.(*peer).run()
      /go/pkg/mod/github.com/jwhited/corebgp@v0.8.5/peer.go:269 +0x2f8
  github.com/jwhited/corebgp.(*peer).start.gowrap1()
      /go/pkg/mod/github.com/jwhited/corebgp@v0.8.5/peer.go:291 +0x34

Previous write at 0x0000011bb370 by goroutine 112:
  github.com/jwhited/corebgp.SetLogger()
      /go/pkg/mod/github.com/jwhited/corebgp@v0.8.5/logger.go:16 +0x3c
  github.com/malbeclabs/doublezero/client/doublezerod/internal/bgp.NewBgpServer()
      /workspaces/doublezero/client/doublezerod/internal/bgp/bgp.go:105 +0x30
  github.com/malbeclabs/doublezero/client/doublezerod/internal/runtime.Run()
      /workspaces/doublezero/client/doublezerod/internal/runtime/run.go:20 +0xe4
  github.com/malbeclabs/doublezero/client/doublezerod/internal/runtime_test.TestEndToEnd_IBRL.func2.10()
      /workspaces/doublezero/client/doublezerod/internal/runtime/run_test.go:391 +0x74

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