panjf2000 / gnet

🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go.
https://gnet.host
Apache License 2.0
9.69k stars 1.04k forks source link

[Bug]: fatal error: concurrent map read and map write #577

Closed iqinlongfei closed 7 months ago

iqinlongfei commented 7 months ago

Actions I've taken before I'm here

What happened?

image

Major version of gnet

v2

Specific version of gnet

v2.3.3

Operating system

Linux

OS version

Linux 5.15.56.bsk.1-amd64 x86_64

Go version

go1.19.2

Relevant log output

fatal error: concurrent map read and map write

goroutine 398788 [running]:
github.com/panjf2000/gnet/v2.(*connMatrix).getConn(...)
    /go/pkg/mod/github.com/panjf2000/gnet/v2@v2.3.3/conn_map.go:66
github.com/panjf2000/gnet/v2.(*eventloop).close(0xc354050380, 0xc4d02c3960, {0x1099680, 0xc50f578860})
    /go/pkg/mod/github.com/panjf2000/gnet/v2@v2.3.3/eventloop_unix.go:174 +0xc5
github.com/panjf2000/gnet/v2.(*conn).write(0xc4d02c3960, {0xc4b0751b30, 0xee, 0xee})
    /go/pkg/mod/github.com/panjf2000/gnet/v2@v2.3.3/connection_unix.go:137 +0x165
github.com/panjf2000/gnet/v2.(*conn).Write(0xc483353680?, {0xc4b0751b30?, 0x0?, 0x0?})
    /go/pkg/mod/github.com/panjf2000/gnet/v2@v2.3.3/connection_unix.go:353 +0x5b

Code snippets (optional)

No response

How to Reproduce

Steps to reproduce the behavior:

  1. Go to '....'
  2. Click on '....'
  3. Do '....'
  4. See '....'

Does this issue reproduce with the latest release?

It can reproduce with the latest release

panjf2000 commented 7 months ago

Did you call some APIs that are not concurrency-safe outside the eventloop? Please provide a reproducer for this issue.