Skip to content
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

packets.(*PingreqPacket).Write(0xc8200f3b60, 0x0, 0x0, 0x0, 0x0), invalid memory address or nil pointer dereference #65

Closed
carl-leopard opened this issue Nov 10, 2016 · 4 comments

Comments

@carl-leopard
Copy link

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x20 pc=0x561e72]
goroutine 38 [running]:
bytes.(*Buffer).WriteTo(0xc82048adf8, 0x0, 0x0, 0x0, 0x0, 0x0)
/usr/local/go/src/bytes/buffer.go:206 +0xc2
org.eclipse.paho.mqtt.golang.git/packets.(*PingreqPacket).Write(0xc8200f3b60, 0x0, 0x0, 0x0, 0x0)
org.eclipse.paho.mqtt.golang.git/packets/pingreq.go:23 +0x83
org%2eeclipse%2epaho%2emqtt%2egolang%2egit.keepalive(0xc8201dc300)
org.eclipse.paho.mqtt.golang.git/ping.go:60 +0x77a
created by org%2eeclipse%2epaho%2emqtt%2egolang%2egit.(*Client).Connect.func1
org.eclipse.paho.mqtt.golang.git/client.go:212 +0x13a1

using it in my project, after running a few days(maybe 10, 0000 times), packets.(*PingreqPacket).Write(0xc8200f3b60, 0x0, 0x0, 0x0, 0x0) will write fail case the err above "invalid memory address or nil pointer dereference"

i use the packets like this :
func main() {
client := MQTT.NewClient(opts)
go publishMessage(
client.Publish() //will be exec every 3 seconds
)
client.Subscribe()
}

@carl-leopard carl-leopard changed the title ping package err packets.(*PingreqPacket).Write(0xc8200f3b60, 0x0, 0x0, 0x0, 0x0), invalid memory address or nil pointer dereference Nov 10, 2016
@alsm
Copy link
Contributor

alsm commented Nov 22, 2016

It looks from the trace there as though you might be using an old version of the library, the repository at org.eclipse.paho.mqtt.golang.git is not up to date compared to the github.com hosted one. Please ensure you are have downloaded and are importing "github.com/eclipse/paho.mqtt.golang"

@carl-leopard
Copy link
Author

It doesn't work. Thanks anyway.

@pshirali
Copy link

@alsm , I've seen this happen with a v1.1.1 as well (though I'm running a custom mod built on top of v1.1.1). The repro is not as frequent; but may be reproducible on long-running/stressed environments.

I put a deferred recovery around the PingreqPacket.Write() to dump the packet contents.

I had also enabled logging on all levels and additional log entries on setConnected, IsConnected, connectionStatus, internalConnLost to track status. Here's a dump of the log:

 :mqtt:    DEBUG | [client]   Connect()
 :mqtt:    DEBUG | [store]    memorystore initialized
 :mqtt:    DEBUG | ----- setConnected: 1
 :mqtt:    DEBUG | [client]   about to write new connect msg
 :mqtt:    DEBUG | [client]   Connect()
 :mqtt:    DEBUG | [store]    memorystore initialized
 :mqtt:    DEBUG | ----- setConnected: 1
 :mqtt:    DEBUG | [client]   about to write new connect msg
 :mqtt:    DEBUG | [client]   Connect()
 :mqtt:    DEBUG | [store]    memorystore initialized
 :mqtt:    DEBUG | ----- setConnected: 1
 :mqtt:    DEBUG | [client]   about to write new connect msg
 :mqtt:    DEBUG | [client]   Connect()
 :mqtt:    DEBUG | [store]    memorystore initialized
 :mqtt:    DEBUG | ----- setConnected: 1
 :mqtt:    DEBUG | [client]   about to write new connect msg
 :mqtt:    DEBUG | [client]   Connect()
 :mqtt:    DEBUG | [store]    memorystore initialized
 :mqtt:    DEBUG | ----- setConnected: 1
 :mqtt:    DEBUG | [client]   about to write new connect msg
 :mqtt:    DEBUG | [client]   socket connected to broker
 :mqtt:    DEBUG | [client]   Using MQTT 3.1.1 protocol
 :mqtt:    DEBUG | [net]      connect started
 :mqtt:    DEBUG | [net]      received connack
 :mqtt:    DEBUG | ----- setConnected: 3
 :mqtt:    DEBUG | [client]   client is connected
 :mqtt:    DEBUG | [client]   Added 4 workers
 :mqtt:    DEBUG | [client]   exit startClient
 :mqtt:    DEBUG | [net]      logic started
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    DEBUG | [net]      outgoing started
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [net]      incoming started
 :mqtt:    DEBUG | [pinger]   keepalive starting
 :mqtt:    DEBUG | [net]      errorWatch started
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | ----- connectionStatus: 3
 :mqtt:    DEBUG | [client]   sending publish message, topic: <<topic>>
 :mqtt:    DEBUG | [net]      obound wrote msg, id: 0
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | ----- connectionStatus: 3
 :mqtt:    DEBUG | [client]   sending publish message, topic: <<topic>>
 :mqtt:    DEBUG | [net]      obound wrote msg, id: 1
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [net]      Received Message
 :mqtt:    DEBUG | [net]      logic got msg on ibound
 :mqtt:    DEBUG | [net]      received pubrec, id: 1
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    DEBUG | [net]      obound priority msg to write, type *packets.PubrelPacket
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [net]      Received Message
 :mqtt:    DEBUG | [net]      logic got msg on ibound
 :mqtt:    DEBUG | [store]    memorystore del: message 1 was deleted
 :mqtt:    DEBUG | [net]      received pubcomp, id: 1
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    DEBUG | [client]   enter Subscribe
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | [client]   enter Subscribe
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | [client]   SUBSCRIBE: dup: false qos: 1 retain: false rLength: 0 MessageID: 0 topics: [<<topics>>]
 :mqtt:    DEBUG | [client]   exit Subscribe
 :mqtt:    DEBUG | [net]      obound priority msg to write, type *packets.SubscribePacket
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [client]   enter Subscribe
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | [client]   SUBSCRIBE: dup: false qos: 1 retain: false rLength: 0 MessageID: 0 topics: [<<topics>>]
 :mqtt:    DEBUG | [client]   exit Subscribe
 :mqtt:    DEBUG | [client]   SUBSCRIBE: dup: false qos: 1 retain: false rLength: 0 MessageID: 0 topics: [<<topics>>]
 :mqtt:    DEBUG | [net]      obound priority msg to write, type *packets.SubscribePacket
 :mqtt:    DEBUG | [client]   exit Subscribe
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [net]      obound priority msg to write, type *packets.SubscribePacket
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [net]      Received Message
 :mqtt:    DEBUG | [net]      logic got msg on ibound
 :mqtt:     WARN | [store]    memorystore del: message 1 not found
 :mqtt:    DEBUG | [net]      received suback, id: 1
 :mqtt:    DEBUG | [net]      granted qoss [0]
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    DEBUG | [net]      Received Message
 :mqtt:    DEBUG | [net]      Received Message
 :mqtt:    DEBUG | [net]      logic got msg on ibound
 :mqtt:     WARN | [store]    memorystore del: message 2 not found
 :mqtt:    DEBUG | [net]      received suback, id: 2
 :mqtt:    DEBUG | [net]      granted qoss [2]
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    DEBUG | [net]      logic got msg on ibound
 :mqtt:     WARN | [store]    memorystore del: message 3 not found
 :mqtt:    DEBUG | [net]      received suback, id: 3
 :mqtt:    DEBUG | [net]      granted qoss [2]
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    DEBUG | [client]   socket connected to broker
 :mqtt:    DEBUG | [client]   Using MQTT 3.1.1 protocol
 :mqtt:    DEBUG | [net]      connect started
 :mqtt:    ERROR | [net]      incoming stopped with error EOF
 :mqtt:    ERROR | [net]      error triggered, stopping
 :mqtt:    DEBUG | *** entered internalConnLost
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | *** internalConnLost: yes we are connected, so proceed
 :mqtt:    DEBUG | [net]      outgoing stopped
 :mqtt:     WARN | [net]      logic stopped
 :mqtt:    DEBUG | [pinger]   keepalive stopped
 :mqtt:    DEBUG | [msgids]   cleaned up
 :mqtt:    DEBUG | ----- setConnected: 0
 :mqtt:    DEBUG | *** internalConnLost: OnConnectionLost handler kicked
 :mqtt:    ERROR | [net]      connect got error read tcp 172.121.3.34:60708->192.168.0.5:22100: use of closed network connection
 :mqtt:    ERROR | [client]   Connecting to ssl://<<address>>:22100 CONNACK was not CONN_ACCEPTED, but rather Connection Error
 :mqtt:    ERROR | [client]   Failed to connect to a broker
 :mqtt:    DEBUG | ----- setConnected: 0
 :mqtt:    DEBUG | [store]    memorystore closed
 :mqtt:    ERROR | [client]   tls: DialWithDialer timed out
 :mqtt:     WARN | [client]   failed to connect to broker, trying next
 :mqtt:    ERROR | [client]   Failed to connect to a broker
 :mqtt:    DEBUG | ----- setConnected: 0
 :mqtt:    ERROR | [store]    Trying to close memory store, but not open
 :mqtt:    DEBUG | [client]   socket connected to broker
 :mqtt:    DEBUG | [client]   Using MQTT 3.1.1 protocol
 :mqtt:    DEBUG | [net]      connect started
 :mqtt:    DEBUG | [net]      received connack
 :mqtt:    DEBUG | ----- setConnected: 3
 :mqtt:    DEBUG | [client]   client is connected
 :mqtt:    DEBUG | [client]   Added 4 workers
 :mqtt:    DEBUG | [client]   exit startClient
 :mqtt:    DEBUG | [net]      incoming started
 :mqtt:    DEBUG | [pinger]   keepalive starting
 :mqtt:    DEBUG | [net]      errorWatch started
 :mqtt:    DEBUG | [net]      outgoing started
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [net]      logic started
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | ----- connectionStatus: 3
 :mqtt:    DEBUG | [client]   sending publish message, topic: <<topic>>
 :mqtt:    DEBUG | [client]   enter Subscribe
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | [client]   SUBSCRIBE: dup: false qos: 1 retain: false rLength: 0 MessageID: 0 topics: [<<topics>>]
 :mqtt:    DEBUG | [client]   exit Subscribe
 :mqtt:    DEBUG | [client]   enter Subscribe
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | [net]      obound priority msg to write, type *packets.SubscribePacket
 :mqtt:    DEBUG | [client]   SUBSCRIBE: dup: false qos: 1 retain: false rLength: 0 MessageID: 0 topics: [<<topics>>]
 :mqtt:    DEBUG | [client]   exit Subscribe
 :mqtt:    DEBUG | [client]   enter Subscribe
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | [client]   SUBSCRIBE: dup: false qos: 1 retain: false rLength: 0 MessageID: 0 topics: [<<topics>>]
 :mqtt:    DEBUG | [client]   exit Subscribe
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [net]      obound priority msg to write, type *packets.SubscribePacket
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [net]      obound priority msg to write, type *packets.SubscribePacket
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [net]      Received Message
 :mqtt:    DEBUG | [net]      logic got msg on ibound
 :mqtt:    ERROR | [store]    Trying to use memory store, but not open
 :mqtt:    DEBUG | [net]      received suback, id: 1
 :mqtt:    DEBUG | [net]      granted qoss [2]
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    DEBUG | [net]      Received Message
 :mqtt:    DEBUG | [net]      logic got msg on ibound
 :mqtt:    ERROR | [store]    Trying to use memory store, but not open
 :mqtt:    DEBUG | [net]      received suback, id: 2
 :mqtt:    DEBUG | [net]      granted qoss [2]
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    DEBUG | [net]      Received Message
 :mqtt:    DEBUG | [net]      logic got msg on ibound
 :mqtt:    ERROR | [store]    Trying to use memory store, but not open
 :mqtt:    DEBUG | [net]      received suback, id: 3
 :mqtt:    DEBUG | [net]      granted qoss [0]
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | ----- connectionStatus: 3
 :mqtt:    DEBUG | [client]   sending publish message, topic: <<topic>>
 :mqtt:    ERROR | [store]    Trying to use memory store, but not open
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: true
 :mqtt:    DEBUG | ----- connectionStatus: 3
 :mqtt:    DEBUG | [client]   sending publish message, topic: <<topic>>
 :mqtt:    ERROR | [store]    Trying to use memory store, but not open
 :mqtt:    DEBUG | [net]      obound wrote msg, id: 2
 :mqtt:    DEBUG | [net]      outgoing waiting for an outbound message
 :mqtt:    DEBUG | [net]      Received Message
 :mqtt:    DEBUG | [net]      logic got msg on ibound
 :mqtt:    ERROR | [store]    Trying to use memory store, but not open
 :mqtt:    DEBUG | [net]      received puback, id: 2
 :mqtt:    DEBUG | [net]      logic waiting for msg on ibound
 :mqtt:    ERROR | [client]   tls: DialWithDialer timed out
 :mqtt:     WARN | [client]   failed to connect to broker, trying next
 :mqtt:    ERROR | [client]   Failed to connect to a broker
 :mqtt:    DEBUG | ----- setConnected: 0
 :mqtt:    ERROR | [store]    Trying to close memory store, but not open
 :mqtt:    DEBUG | [pinger]   ping check 4
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [pinger]   ping check 9
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [pinger]   ping check 14
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [pinger]   ping check 19
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [pinger]   ping check 24
 :mqtt:    DEBUG | [pinger]   keepalive sending ping
 :mqtt:    ********* PINGREQ **********
 :mqtt:    Packet: PINGREQ: dup: false qos: 0 retain: false rLength: 0
 :mqtt:    Packet(s): PINGREQ: dup: false qos: 0 retain: false rLength: 0
 :mqtt:    FixedHeader: PINGREQ: dup: false qos: 0 retain: false rLength: 0
 :mqtt:    Packed: {[192 0] 0 [192 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0] 0}
 :mqtt:    ********* PINGREQ **********
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [pinger]   ping check 5
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    ERROR | [net]      incoming stopped with error EOF
 :mqtt:    ERROR | [net]      error triggered, stopping
 :mqtt:    DEBUG | *** entered internalConnLost
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [pinger]   ping check 10
 :mqtt:    DEBUG | [client]   enter Publish
 :mqtt:    DEBUG | ----- IsConnected: false (default)
 :mqtt:    DEBUG | [client]   enter Publish

@MattBrittan
Copy link
Contributor

Closing due to age/inactivity. Please feel free to reopen if this issue is occurring with the current release.

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

4 participants