Skip to content

A core dump occurs during TCP communication. #68881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xuyinghao opened this issue Aug 15, 2024 · 2 comments
Closed

A core dump occurs during TCP communication. #68881

xuyinghao opened this issue Aug 15, 2024 · 2 comments

Comments

@xuyinghao
Copy link

xuyinghao commented Aug 15, 2024

Go version

go version go1.20.4 linux/amd64

Output of go env in your module/workspace:

GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB="*"
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/mnt/data_disk/code/xyh/smartBench/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2150994079=/tmp/go-build -gno-record-gcc-switches"

What did you do?

进程间正常 tcp 通信

type masterProcessSlave struct {
	conn            net.Conn
}


func (sc *masterProcessSlave) ProcessSlaveMsg() {
	if sc.conn != nil {
		br := bufio.NewReader(sc.conn)
		dec := json.NewDecoder(br)
		var exit bool
		for {
			if exit {
				break
			}
			var content Message
			err := dec.Decode(&content)
			if err != nil {
				fmt.Println(err)
				panic(sc.SlaveLabel + " lost connected")
			}
			fmt.Println(content)
               }
      }
}

func masterProcessSlave(listen net.Listener) {
	for {
		client, err := listen.Accept()
		if err != nil {
			panic(err)
		}
		slave := tcp.NewMasterProcessSlave(client)
		go slave.ProcessSlaveMsg()
	}
}


func (s *SlaveProcessMaster) SendMsgToMaster(no MsgNo, data []byte) {
	if s.conn != nil {
		req := &Message{MsgNo: no, Data: data}
		bytes, err := json.Marshal(req)
		if err != nil {
			panic(errstd.JsonSerializerErr)
		}
		_, errTcp := s.conn.Write(bytes)
		if errTcp != nil {
			fmt.Printf("send master err %v", errTcp)
			panic(errstd.CommunicationErr)
		}

	}
}

What did you see happen?

Use the net package of the Go language to perform inter-process TCP communication. The receiving-end page terminal reports EOF, and the sending-end process experiences coredump. The stack information is as follows. The IP address used for communication is 127.0.0.1.

(gdb) bt
#0 0x0000000000572350 in net.init () at /usr/local/go/src/net/addrselect.go:231
#1 0x00007fc8c8709c58 in ?? ()
#2 0x00007ffd24f38d90 in ?? ()
#3 0x0000000000465361 in runtime.name.name (n=..., ~r0=...) at /usr/local/go/src/runtime/type.go:459
#4 0x00007fc8c8709c20 in ?? ()
#5 0x0000000000000000 in ?? ()

What did you expect to see?

The service is normal.

@seankhliao
Copy link
Member

1.20 isn't a supported release anymore.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants