esp-idf mqtt problem at strdup

_wa1a_
Posts: 1
Joined: Wed Jun 10, 2020 9:29 pm

esp-idf mqtt problem at strdup

Postby _wa1a_ » Wed Jun 10, 2020 9:41 pm

Hi all,

I use esp-idf (4.0.1)on a esp-wroom-32.
I try to start the mqtt component. If i call esp_mqtt_client_init i ran into an execption at line 204 in mqtt_client.c.
The exception occours when a strdup is performed.

The backtrace is as follows:

D (9811) MQTT_CLIENT: MQTT client_id=ESP32_9d83600m
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400014fd PS : 0x00060530 A0 : 0x80001459 A1 : 0x3ffbb9b0
A2 : 0x800d1ee4 A3 : 0x800d1ee0 A4 : 0x000000ff A5 : 0x0000ff00
A6 : 0x00ff0000 A7 : 0xff000000 A8 : 0x00000000 A9 : 0x3ffbb980
A10 : 0x3ffbbc1c A11 : 0x0000000b A12 : 0x00000001 A13 : 0x3ffbb850
A14 : 0x00000036 A15 : 0x3ffbb850 SAR : 0x00000004 EXCCAUSE: 0x0000001c
EXCVADDR: 0x800d1ee4 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff

ELF file SHA256: 8267ed4c37de7095

Backtrace: 0x400014fa:0x3ffbb9b0 0x40001456:0x3ffbb9c0 0x40001445:0x3ffbb9e0 0x400d3501:0x3ffbba00 0x400d3b1a:0x3ffbba30 0x400d2207:0x3ffbba80 0x400d1ac8:0x3ffbbb30 0x400d4e02:0x3ffbbb70 0x4009023d:0x3ffbbb90
#0 0x400014fa:0x3ffbb9b0 in ?? ??:0
#1 0x40001456:0x3ffbb9c0 in ?? ??:0
#2 0x40001445:0x3ffbb9e0 in ?? ??:0
#3 0x400d3501:0x3ffbba00 in esp_mqtt_set_config at /home/wa1a/.platformio/packages/framework-espidf/components/mqtt/esp-mqtt/mqtt_client.c:204
#4 0x400d3b1a:0x3ffbba30 in esp_mqtt_client_init at /home/wa1a/.platformio/packages/framework-espidf/components/mqtt/esp-mqtt/mqtt_client.c:432


I am a little bit lost what the problem is. Seems like something during memory allocation.
I hope some of you guys can point me in the right direction :-)
thanks in advance!

wa1a

nvannote
Posts: 51
Joined: Thu Nov 14, 2019 10:42 pm

Re: esp-idf mqtt problem at strdup

Postby nvannote » Thu Jun 11, 2020 2:12 am

It would appear that your esp_mqtt_client_config_t structure was not initialized properly prior to calling esp_mqtt_client_init.

You will wan't to check that.

Best Regards

nvannote
Posts: 51
Joined: Thu Nov 14, 2019 10:42 pm

Re: esp-idf mqtt problem at strdup

Postby nvannote » Thu Jun 11, 2020 3:22 am

For reference; I came to that conclusion as.

Looking at line 204; it did indeed fail in strdup. strdup usually breaks down to a simple strlen/malloc/strcpy sequence. If the allocation failed within strdup, strdup would have failed gracefully and that would have been reported on line 205.

Looking at the panic, LoadProhibited and EXCVADDR. The address does look to be invalid.

Hence, it looks like your config structure wasn't initialized properly; Or what you passed to esp_mqtt_client_init isn't what you thought it was.

More information can be found here regarding the panics and whatnot.

https://docs.espressif.com/projects/esp ... ion-errors

Best Regards

Who is online

Users browsing this forum: No registered users and 57 guests