aws / aws-iot-device-sdk-embedded-C

SDK for connecting to AWS IoT from a device using embedded C.
MIT License
975 stars 623 forks source link

segmentation fault on shadow demo #1843

Closed certabitmh closed 1 year ago

certabitmh commented 1 year ago

Hi,

when trying to run shadow_demo_main (202211.00) on cross compiled target (host=x86_64-pc-linux-gnu, target=arm-buildroot-linux-gnueabi") , I get a segfault when connecting mqtt:

output on target: [INFO] [SHADOW_DEMO] [shadow_demo_helpers.c:444] Establishing a TLS session to myendpoint-ats.iot.eu-west-1.amazonaws.com:8883.

gdb output:

Reading symbols from shadow_demo_main...done.
Reading /lib/ld-linux.so.3 from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to access files locally instead.
Reading /lib/ld-linux.so.3 from remote target...
0xb6fce9f0 in _start () from target:/lib/ld-linux.so.3

(gdb) c
Continuing.

Reading /usr/lib/libclock_posix.so from remote target...
Reading /usr/lib/libopenssl_posix.so from remote target...
Reading /usr/lib/libsockets_posix.so from remote target...
Reading /usr/lib/libssl.so.1.1 from remote target...
Reading /usr/lib/libcrypto.so.1.1 from remote target...
Reading /lib/libc.so.6 from remote target...
Reading /lib/libdl.so.2 from remote target...
Reading /lib/libpthread.so.0 from remote target...
Reading /lib/libatomic.so.1 from remote target...
Reading /lib/libnss_files.so.2 from remote target...
Reading /lib/libnss_dns.so.2 from remote target...
Reading /lib/libresolv.so.2 from remote target...
Reading /usr/lib/libz.so from remote target...

Program received signal SIGSEGV, Segmentation fault.
0xb6ff01f4 in ?? ()

Backtrace gives:

(gdb) backtrace 
#0  0xb6ff01f4 in ?? ()
#1  0x0001398c in sendMessageVector (pContext=pContext@entry=0x3107c <mqttContext>, 
    pIoVec=pIoVec@entry=0xbefff8b8, ioVecCount=ioVecCount@entry=5)
    at /path-to-sdk/libraries/standard/coreMQTT/source/core_mqtt.c:782
#2  0x0001484c in sendConnectWithoutCopy (remainingLength=<optimized out>, pWillInfo=0x0, 
    pConnectInfo=0xbefff974, pContext=0x3107c <mqttContext>)
    at /path-to-sdk/libraries/standard/coreMQTT/source/core_mqtt.c:2236
#3  MQTT_Connect (pContext=pContext@entry=0x3107c <mqttContext>, pConnectInfo=0xbefff974, 
    pConnectInfo@entry=0xbefff96c, pWillInfo=pWillInfo@entry=0x0, timeoutMs=timeoutMs@entry=1000, 
    pSessionPresent=0xbefff94d, pSessionPresent@entry=0xbefff945)
    at /path-to-sdk/libraries/standard/coreMQTT/source/core_mqtt.c:2654
#4  0x00012738 in EstablishMqttSession (eventCallback=eventCallback@entry=0x12f50 <eventCallback>)
    at /path-to-sdk/demos/shadow/shadow_demo_main/shadow_demo_helpers.c:811
#5  0x00011bc0 in main (argc=<optimized out>, argv=<optimized out>)
    at /path-to-sdk/demos/shadow/shadow_demo_main/shadow_demo_main.c:681
(gdb)
rawalexe commented 1 year ago

After researching the problem we found that the TransportInterface_t transport was uninitialized and was causing the segmentation fault. The bug is patched with this pull request

rawalexe commented 1 year ago

The problem has been patched with the new PR. I'm closing the issue but if it persists please do reopen it.