go-stomp / stomp

Go language library for STOMP protocol
Apache License 2.0
318 stars 96 forks source link

After a frame error, call to Subscribe results in a SIGSEGV #98

Open jimmy-moore opened 3 years ago

jimmy-moore commented 3 years ago

It'd be nice if it just returned an error to say the connection has been closed

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x80 pc=0x677a41]

goroutine 1 [running]: github.com/go-stomp/stomp/v3.(*Conn).Subscribe(0x0, 0xc000025320, 0x90, 0x0, 0xc000cd1bc0, 0x4, 0x4, 0x0, 0x0, 0x0) github.com/go-stomp/stomp/v3@v3.0.0/conn.go:595 +0x61

worg commented 3 years ago

We already check for closed connection status on subscribe https://github.com/go-stomp/stomp/blob/master/conn.go#L597 How do you get the SSIGSEV when calling the subscribe call?

jimmy-moore commented 3 years ago

Yeah I'm not sure how it's getting it yet. I see you already check, but something doesn't seem right. I'll try to narrow down the issue...

niuhuan commented 1 year ago

connect use ssl and network is not good can got this panic

wait a moment afert subscribe

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x40 pc=0x1021bf13c]

goroutine 1 [running]:
github.com/go-stomp/stomp/v3.(*Conn).createAckNackFrame(0x140001666c0?, 0x14000119f60?, 0x1?)
        /Volumes/DATA/Runtimes/GoPATH/pkg/mod/github.com/go-stomp/stomp/v3@v3.0.5/conn.go:723 +0x7c
github.com/go-stomp/stomp/v3.(*Conn).Ack(0x0?, 0x1021c5e4f?)
        /Volumes/DATA/Runtimes/GoPATH/pkg/mod/github.com/go-stomp/stomp/v3@v3.0.5/conn.go:674 +0x28
main.main()
        /Volumes/DATA/Projects/club-server/club-server/afdian_mq_insert/rev/main.go:26 +0xf8

msg in nil, I think i need reconnect.

24  for {
25      msg := <-sub.C
26      stompConn.Ack(msg)
27      println(string(msg.Body))
28  }
worg commented 1 year ago

How are you connecting? Also remember that subscription.C may return nil messages so it's the consumer responsibility to make sure you're operating on a valid message and it can be acked before trying to do so

On Mon, 6 Feb 2023, 10:25 niuhuan, @.***> wrote:

connect use ssl and network is not good can got this panic

wait a moment afert subscribe

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x2 addr=0x40 pc=0x1021bf13c]

goroutine 1 [running]:github.com/go-stomp/stomp/v3.(*Conn).createAckNackFrame(0x140001666c0?, 0x14000119f60?, 0x1?) @./conn.go:723 +0x7cgithub.com/go-stomp/stomp/v3.(Conn).Ack(0x0?, 0x1021c5e4f?) **@.***/conn.go:674 +0x28 main.main() /Volumes/DATA/Projects/club-server/club-server/afdian_mq_insert/rev/main.go:26 +0xf8

— Reply to this email directly, view it on GitHub https://github.com/go-stomp/stomp/issues/98#issuecomment-1419363126, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFE4G6ZUAIUZ3HSYANWNN3WWEQXRANCNFSM43TCA5KA . You are receiving this because you commented.Message ID: @.***>