eclipse / paho.mqtt-sn.embedded-c

Paho C MQTT-SN gateway and libraries for embedded systems. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
315 stars 178 forks source link

MQTTSN-Gateway: When using more then one xbee, segfaults. #35

Closed PaulKierstead closed 7 years ago

PaulKierstead commented 7 years ago

Have two xbee clients doing periodic publishes, so when the gateway comes up, they will both reconnect. This always causes a seg fault.

 ***************************************************************************
 * MQTT-SN Transparent Gateway
 * Part of Project Paho in Eclipse
 * (http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt-sn.embedded-c.git/)
 *
 * Author : Tomoaki YAMAGUCHI
 * Version: 0.9.0
 ***************************************************************************

20161012 203808.829 PahoGateway-01 has been started.

 ConfigFile:  ./gateway.conf
 SensorN/W:   API mode 1, Baudrate 9600, SerialDevice /dev/ttyUSB1
 Broker:      localhost : 1883, 8883
 RootCApath:  (null)
 RootCAfile:  (null)
 ClientCerts: (null)
 00 59 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7e
===> Recv:     00 0f 90 00 13 a2 00 40 a6 92 b1 8b 00 01 03 09 30 c9    checksum ok
20161012 203809.097   WILLMSG           <---  Non Active Client !                 09 30

===> Send:     7e 00 10 10 01 00 13 a2 00 40 a6 92 b1 8b 00 00 00
     Payload:  02 18   checksum   6b
 7e
===> Recv:     00 07 8b 01 8b 00 00 00 00 e8    checksum ok
20161012 203809.152   DISCONNECT        --->  Non Active Client !                 18
 7e
===> Recv:     00 1e 90 00 13 a2 00 40 a6 92 b1 8b 00 01 12 04 0c 01 00 3c 53 6f 6d 65 43 6c 69 65 6e 74 49 44 26    checksum ok

20161012 203809.235   CONNECT           <---  SomeClientID                        04 0C 01 00 3C 53 6F 6D 65 43 6C 69 65 6E 74 49 44
     PacketHandleTask gets CONNECT      from the client.

===> Send:     7e 00 10 10 02 00 13 a2 00 40 a6 92 b1 8b 00 00 00
     Payload:  02 06   checksum   7c
 7e
===> Recv:     00 07 8b 02 8b 00 00 00 00 e7    checksum ok
20161012 203809.290   WILLTOPICREQ      --->  SomeClientID                        06
 7e
===> Recv:     00 20 90 00 13 a2 00 40 a6 92 b1 8b 00 01 14 07 10 6d 71 74 74 73 6e 74 65 73 74 2f 73 74 61 74 75 73 a0    checksum ok
20161012 203809.376   WILLTOPIC         <---  SomeClientID                        07 10 6D 71 74 74 73 6E 74 65 73 74 2F 73 74 61 74 75 73
     PacketHandleTask gets WILLTOPIC      from the client.

===> Send:     7e 00 10 10 03 00 13 a2 00 40 a6 92 b1 8b 00 00 00
     Payload:  02 08   checksum   79
 7e
===> Recv:     00 07 8b 03 8b 00 00 00 00 e6    checksum ok
20161012 203809.433   WILLMSGREQ        --->  SomeClientID                        08
 7e
===> Recv:     00 0f 90 00 13 a2 00 40 a6 92 b1 8b 00 01 03 09 30 c9    checksum ok
20161012 203809.489   WILLMSG           <---  SomeClientID                        09 30
     PacketHandleTask gets WILLMSG      from the client.
20161012 203809.512   CONNECT           --->  SomeClientID                        10 2E 00 04 4D 51 54 54 04 26 00 3C 00 0C 53 6F 6D 65 43 6C 69 65 6E 74 49 44 00 11 6D 71 74 74 73 6E 74 65 73 74 2F 73 74 61 74 75 73 00 01 30
20161012 203809.517   CONNACK           <---  SomeClientID                        20 02 00 00
     PacketHandleTask gets CONNACK      from the broker.

===> Send:     7e 00 11 10 04 00 13 a2 00 40 a6 92 b1 8b 00 00 00
     Payload:  03 05 00   checksum   7a
 7e
===> Recv:     00 07 8b 04 8b 00 00 00 00 e5    checksum ok
20161012 203809.576   CONNACK           --->  SomeClientID                        05 00
 7e
===> Recv:     00 23 90 00 13 a2 00 40 a6 92 b1 8b 00 01 17 0a 00 00 00 52 6d 71 74 74 73 6e 74 65 73 74 2f 73 74 61 74 75 73 58    checksum ok

20161012 203809.672   REGISTER    0052  <---  SomeClientID                        0A 00 00 00 52 6D 71 74 74 73 6E 74 65 73 74 2F 73 74 61 74 75 73
     PacketHandleTask gets REGISTER  0052 from the client.

===> Send:     7e 00 15 10 05 00 13 a2 00 40 a6 92 b1 8b 00 00 00
     Payload:  07 0b 00 01 00 52 00   checksum   1c
 7e
===> Recv:     00 07 8b 05 8b 00 00 00 00 e4    checksum ok
20161012 203809.732   REGACK      0052  --->  SomeClientID                        0B 00 01 00 52 00
 7e
===> Recv:     00 24 90 00 13 a2 00 40 a6 92 b1 8b 00 01 18 0a 00 00 00 53 6d 71 74 74 73 6e 74 65 73 74 2f 43 6f 75 6e 74 65 72 1a    checksum ok

20161012 203809.846   REGISTER    0053  <---  SomeClientID                        0A 00 00 00 53 6D 71 74 74 73 6E 74 65 73 74 2F 43 6F 75 6E 74 65 72
     PacketHandleTask gets REGISTER  0053 from the client.

===> Send:     7e 00 15 10 06 00 13 a2 00 40 a6 92 b1 8b 00 00 00
     Payload:  07 0b 00 02 00 53 00   checksum   19
 7e
===> Recv:     00 07 8b 06 8b 00 00 00 00 e3    checksum ok
20161012 203809.906   REGACK      0053  --->  SomeClientID                        0B 00 02 00 53 00
 7e
===> Recv:     00 22 90 00 13 a2 00 40 a6 92 b1 8b 00 01 16 12 00 00 54 6d 71 74 74 73 6e 74 65 73 74 2f 70 69 6e 2f 31 32 1a    checksum ok

20161012 203810.012   SUBSCRIBE   0054  <---  SomeClientID                        12 00 00 54 6D 71 74 74 73 6E 74 65 73 74 2F 70 69 6E 2F 31 32
     PacketHandleTask gets SUBSCRIBE  0054 from the client.
20161012 203810.016   SUBSCRIBE   0054  --->  SomeClientID                        82 16 00 54 00 11 6D 71 74 74 73 6E 74 65 73 74 2F 70 69 6E 2F 31 32 00
20161012 203810.019   SUBACK      0054  <---  SomeClientID                        90 03 00 54 00
     PacketHandleTask gets SUBACK  0054 from the broker.

===> Send:     7e 00 16 10 07 00 13 a2 00 40 a6 92 b1 8b 00 00 00
     Payload:  08 13 00 00 03 00 54 00   checksum   0d
 7e
===> Recv:     00 07 8b 07 8b 00 00 00 00 e2    checksum ok
20161012 203810.082   SUBACK      0054  --->  SomeClientID                        13 00 00 03 00 54 00
 7e
===> Recv:     00 22 90 00 13 a2 00 40 a6 92 b1 8b 00 01 16 12 00 00 55 6d 71 74 74 73 6e 74 65 73 74 2f 70 69 6e 2f 31 33 18    checksum ok

20161012 203810.184   SUBSCRIBE   0055  <---  SomeClientID                        12 00 00 55 6D 71 74 74 73 6E 74 65 73 74 2F 70 69 6E 2F 31 33
     PacketHandleTask gets SUBSCRIBE  0055 from the client.
20161012 203810.188   SUBSCRIBE   0055  --->  SomeClientID                        82 16 00 55 00 11 6D 71 74 74 73 6E 74 65 73 74 2F 70 69 6E 2F 31 33 00
20161012 203810.190   SUBACK      0055  <---  SomeClientID                        90 03 00 55 00
     PacketHandleTask gets SUBACK  0055 from the broker.

===> Send:     7e 00 16 10 08 00 13 a2 00 40 a6 92 b1 8b 00 00 00
     Payload:  08 13 00 00 04 00 55 00   checksum   0a
 7e
===> Recv:     00 07 8b 08 8b 00 00 00 00 e1    checksum ok
20161012 203810.252   SUBACK      0055  --->  SomeClientID                        13 00 00 04 00 55 00
 7e
===> Recv:     00 15 90 00 13 a2 00 40 a6 92 b1 8b 00 01 09 0c 10 00 01 00 00 31 00 ae    checksum ok

20161012 203810.330   PUBLISH     0000  <---  SomeClientID                        0C 10 00 01 00 00 31 00
     PacketHandleTask gets PUBLISH  0000 from the client.
20161012 203810.334   PUBLISH     0000  --->  SomeClientID                        31 15 00 11 6D 71 74 74 73 6E 74 65 73 74 2F 73 74 61 74 75 73 31 00
 7e
===> Recv:     00 14 90 00 13 a2 00 40 a6 92 b1 8b 00 01 08 0c 00 00 02 00 00 33 bc    checksum ok

20161012 203810.355   PUBLISH     0000  <---  SomeClientID                        0C 00 00 02 00 00 33
     PacketHandleTask gets PUBLISH  0000 from the client.
20161012 203810.357   PUBLISH     0000  --->  SomeClientID                        30 15 00 12 6D 71 74 74 73 6E 74 65 73 74 2F 43 6F 75 6E 74 65 72 33
 7e
===> Recv:     00 14 90 00 13 a2 00 40 f1 6e b5 4a 81 01 08 0c 62 58 31 00 00 43 58    checksum ok

20161012 203810.988   PUBLISH     0000  <---  Non Active Client !                 0C 62 58 31 00 00 43

===> Send:     7e 00 10 10 09 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  02 18   checksum   f8
 7e
===> Recv:     00 07 8b 09 4a 81 00 00 00 a0    checksum ok
20161012 203811.071   DISCONNECT        --->  SomeClientID                        18
 7e
===> Recv:     00 21 90 00 13 a2 00 40 f1 6e b5 4a 81 01 15 04 0c 01 00 3c 41 6e 6f 74 68 65 72 43 6c 69 65 6e 74 49 44 7b    checksum ok

20161012 203811.197   CONNECT           <---  AnotherClientID                     04 0C 01 00 3C 41 6E 6F 74 68 65 72 43 6C 69 65 6E 74 49 44
     PacketHandleTask gets CONNECT      from the client.

===> Send:     7e 00 10 10 0a 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  02 06   checksum   09
 7e
===> Recv:     00 07 8b 0a 4a 81 00 00 00 9f    checksum ok
20161012 203811.322   WILLTOPICREQ      --->  AnotherClientID                     06
 7e
===> Recv:     00 1b 90 00 13 a2 00 40 f1 6e b5 4a 81 01 0f 07 10 74 65 73 74 32 2f 73 74 61 74 75 73 af    checksum ok
20161012 203811.403   WILLTOPIC         <---  AnotherClientID                     07 10 74 65 73 74 32 2F 73 74 61 74 75 73
     PacketHandleTask gets WILLTOPIC      from the client.

===> Send:     7e 00 10 10 0b 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  02 08   checksum   06
 7e
===> Recv:     00 07 8b 0b 4a 81 00 00 00 9e    checksum ok
20161012 203811.488   WILLMSGREQ        --->  AnotherClientID                     08
 7e
===> Recv:     00 0f 90 00 13 a2 00 40 f1 6e b5 4a 81 01 03 09 30 5e    checksum ok
20161012 203811.535   WILLMSG           <---  AnotherClientID                     09 30
     PacketHandleTask gets WILLMSG      from the client.
20161012 203811.545   CONNECT           --->  AnotherClientID                     10 2C 00 04 4D 51 54 54 04 26 00 3C 00 0F 41 6E 6F 74 68 65 72 43 6C 69 65 6E 74 49 44 00 0C 74 65 73 74 32 2F 73 74 61 74 75 73 00 01 30
20161012 203811.694   CONNACK           <---  AnotherClientID                     20 02 00 00
     PacketHandleTask gets CONNACK      from the broker.

===> Send:     7e 00 11 10 0c 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  03 05 00   checksum   07
 7e
===> Recv:     00 07 8b 0c 4a 81 00 00 00 9d    checksum ok
20161012 203811.774   CONNACK           --->  AnotherClientID                     05 00
 7e
===> Recv:     00 1e 90 00 13 a2 00 40 f1 6e b5 4a 81 01 12 0a 00 00 00 15 74 65 73 74 32 2f 73 74 61 74 75 73 a4    checksum ok

20161012 203811.913   REGISTER    0015  <---  AnotherClientID                     0A 00 00 00 15 74 65 73 74 32 2F 73 74 61 74 75 73
     PacketHandleTask gets REGISTER  0015 from the client.

===> Send:     7e 00 15 10 0d 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  07 0b 00 01 00 15 00   checksum   e6
 7e
===> Recv:     00 07 8b 0d 4a 81 00 00 00 9c    checksum ok
20161012 203811.991   REGACK      0015  --->  AnotherClientID                     0B 00 01 00 15 00
 7e
===> Recv:     00 1b 90 00 13 a2 00 40 f1 6e b5 4a 81 01 0f 0a 00 00 00 16 74 65 73 74 32 2f 73 77 30 30    checksum ok

20161012 203812.087   REGISTER    0016  <---  AnotherClientID                     0A 00 00 00 16 74 65 73 74 32 2F 73 77 30
     PacketHandleTask gets REGISTER  0016 from the client.

===> Send:     7e 00 15 10 0e 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  07 0b 00 02 00 16 00   checksum   e3
 7e
===> Recv:     00 07 8b 0e 4a 81 00 00 00 9b    checksum ok
20161012 203812.217   REGACK      0016  --->  AnotherClientID                     0B 00 02 00 16 00
 7e
===> Recv:     00 1d 90 00 13 a2 00 40 f1 6e b5 4a 81 01 11 12 00 00 17 74 65 73 74 32 2f 70 69 6e 2f 31 32 66    checksum ok

20161012 203812.278   SUBSCRIBE   0017  <---  AnotherClientID                     12 00 00 17 74 65 73 74 32 2F 70 69 6E 2F 31 32
     PacketHandleTask gets SUBSCRIBE  0017 from the client.
20161012 203812.282   SUBSCRIBE   0017  --->  AnotherClientID                     82 11 00 17 00 0C 74 65 73 74 32 2F 70 69 6E 2F 31 32 00
20161012 203812.284   SUBACK      0017  <---  AnotherClientID                     90 03 00 17 00

20161012 203812.285   PUBLISH     0000  <---  AnotherClientID                     31 0F 00 0C 74 65 73 74 32 2F 70 69 6E 2F 31 32 30
     PacketHandleTask gets SUBACK  0017 from the broker.
     PacketHandleTask gets PUBLISH  0000 from the broker.

===> Send:     7e 00 16 10 0f 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  08 13 00 00 03 00 17 00   checksum   d7
 7e
===> Recv:     00 07 8b 0f 4a 81 00 00 00 9a    checksum ok
20161012 203812.364   SUBACK      0017  --->  AnotherClientID                     13 00 00 03 00 17 00
 7e
===> Recv:     00 1d 90 00 13 a2 00 40 f1 6e b5 4a 81 01 11 12 00 00 18 74 65 73 74 32 2f 70 69 6e 2f 31 33 64    checksum ok

20161012 203812.494   SUBSCRIBE   0018  <---  AnotherClientID                     12 00 00 18 74 65 73 74 32 2F 70 69 6E 2F 31 33
     PacketHandleTask gets SUBSCRIBE  0018 from the client.
20161012 203812.498   SUBSCRIBE   0018  --->  AnotherClientID                     82 11 00 18 00 0C 74 65 73 74 32 2F 70 69 6E 2F 31 33 00
20161012 203812.500   SUBACK      0018  <---  AnotherClientID                     90 03 00 18 00

20161012 203812.501   PUBLISH     0000  <---  AnotherClientID                     31 0F 00 0C 74 65 73 74 32 2F 70 69 6E 2F 31 33 31
     PacketHandleTask gets SUBACK  0018 from the broker.
     PacketHandleTask gets PUBLISH  0000 from the broker.

===> Send:     7e 00 16 10 10 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  08 0c 10 00 03 00 00 30   checksum   b4
 7e
===> Recv:     00 07 8b 10 4a 81 00 00 00 99    checksum ok
20161012 203812.591   PUBLISH     0000  --->  AnotherClientID                     0C 10 00 03 00 00 30
 7e
===> Recv:     00 14 90 00 13 a2 00 40 f1 6e b5 4a 81 01 08 0c 62 58 31 00 00 41 5a    checksum ok

20161012 203815.969   PUBLISH     0000  <---  AnotherClientID                     0C 62 58 31 00 00 41
     PacketHandleTask gets PUBLISH  0000 from the client.
20161012 203815.977   PUBLISH     0000  --->  AnotherClientID                     36 07 00 02 58 31 00 00 41
 7e
===> Recv:     00 14 90 00 13 a2 00 40 f1 6e b5 4a 81 01 08 0c 62 58 31 00 00 42 59    checksum ok

20161012 203820.966   PUBLISH     0000  <---  AnotherClientID                     0C 62 58 31 00 00 42
     PacketHandleTask gets PUBLISH  0000 from the client.
20161012 203820.969   PUBLISH     0000  --->  AnotherClientID                     36 07 00 02 58 31 00 00 42
 7e
===> Recv:     00 1d 90 00 13 a2 00 40 f1 6e b5 4a 81 01 11 12 80 00 18 74 65 73 74 32 2f 70 69 6e 2f 31 33 e4    checksum ok

20161012 203822.390   SUBSCRIBE   0018  <---  AnotherClientID                     12 80 00 18 74 65 73 74 32 2F 70 69 6E 2F 31 33
     PacketHandleTask gets SUBSCRIBE  0018 from the client.
Error: BrokerSendTask can't send a packet to the broker errno=32 AnotherClientID
*** Error in `Build/MQTT-SNGateway': double free or corruption (fasttop): 0xb3f00650 ***
./run_gateway: line 1: 16611 Aborted                 Build/MQTT-SNGateway -f gateway.conf
ty4tw commented 7 years ago

Thanks Paul, Pls try my development branch of my forked repo.

PaulKierstead commented 7 years ago

So far the developmeny branch is very stable and does not segfault. Thank you. I'll try and let it run for a while longer and restart the end nodes a bit and such.

PaulKierstead commented 7 years ago

Ran it overnight with 2 nodes and it is running well.