nbio
nbio copied to clipboard
Data race in http processor
Hi,
We ran into this data race during our testing. Perhaps another PR like https://github.com/lesismal/nbio/pull/447 would fix it?
[2025-12-02T00:31:57Z] ==================
[2025-12-02T00:31:57Z] WARNING: DATA RACE
[2025-12-02T00:31:57Z] Read at 0x00c0008782a0 by goroutine 348:
[2025-12-02T00:31:57Z] github.com/lesismal/nbio/nbhttp.(*Conn).RemoteAddr()
[2025-12-02T00:31:57Z] <autogenerated>:1 +0x31
[2025-12-02T00:31:57Z] github.com/lesismal/nbio/nbhttp.(*ServerProcessor).OnComplete()
[2025-12-02T00:31:57Z] /go/pkg/mod/github.com/lesismal/[email protected]/nbhttp/processor.go:230 +0x68
[2025-12-02T00:31:57Z] github.com/lesismal/nbio/nbhttp.NewEngine.func7()
[2025-12-02T00:31:57Z] /go/pkg/mod/github.com/lesismal/[email protected]/nbhttp/engine.go:1184 +0x54
[2025-12-02T00:31:57Z] github.com/lesismal/nbio.(*Engine).OnData.func1()
[2025-12-02T00:31:57Z] /go/pkg/mod/github.com/lesismal/[email protected]/engine.go:352 +0x65
[2025-12-02T00:31:57Z] github.com/lesismal/nbio.(*poller).readWriteLoop()
[2025-12-02T00:31:57Z] /go/pkg/mod/github.com/lesismal/[email protected]/poller_epoll.go:280 +0x594
[2025-12-02T00:31:57Z]
[2025-12-02T00:31:57Z] Previous write at 0x00c0008782a0 by goroutine 349:
[2025-12-02T00:31:57Z] github.com/lesismal/nbio/nbhttp.(*Engine).listen.func1()
[2025-12-02T00:31:57Z] /go/pkg/mod/github.com/lesismal/[email protected]/nbhttp/engine.go:340 +0x19c
[2025-12-02T00:31:57Z]
[2025-12-02T00:31:57Z] Goroutine 348 (running) created at:
[2025-12-02T00:31:57Z] github.com/lesismal/nbio.(*Engine).Start()
[2025-12-02T00:31:57Z] /go/pkg/mod/github.com/lesismal/[email protected]/engine_unix.go:89 +0x297
[2025-12-02T00:31:57Z] github.com/braze-inc/dust/testing/e2e_tests.setupServer.func2()
[2025-12-02T00:31:57Z] /app/testing/e2e_tests/test_utils.go:279 +0x110
[2025-12-02T00:31:57Z]
[2025-12-02T00:31:57Z] Goroutine 349 (running) created at:
[2025-12-02T00:31:57Z] github.com/lesismal/nbio/nbhttp.(*Engine).listen()
[2025-12-02T00:31:57Z] /go/pkg/mod/github.com/lesismal/[email protected]/nbhttp/engine.go:332 +0xd2
[2025-12-02T00:31:57Z] github.com/braze-inc/dust/testing/e2e_tests.setupServer.func2()
[2025-12-02T00:31:57Z] /app/testing/e2e_tests/test_utils.go:279 +0x110
[2025-12-02T00:31:57Z] ==================
[2025-12-02T00:31:57Z] ==================
[2025-12-02T00:31:57Z] WARNING: DATA RACE
[2025-12-02T00:31:57Z] Read at 0x00c0007a6600 by goroutine 348:
[2025-12-02T00:31:57Z] net.(*TCPAddr).String()
[2025-12-02T00:31:57Z] /usr/local/go/src/net/tcpsock.go:48 +0x4d
[2025-12-02T00:31:57Z] github.com/lesismal/nbio/nbhttp.(*ServerProcessor).OnComplete()"
our code on version 1.6.7:
srv := nbhttp.NewEngine(nbhttp.Config{
Network: "tcp",
Addrs: []string{fmt.Sprintf(":%v", cfg.Port)},
Handler: handler,
})
Thank you for your feedback!
https://github.com/lesismal/nbio/pull/447 is to disable data race warnings. I have added norace for all funcs. But for this case, I am not sure how to disable it :joy: