Stack overflow when repeat Mongoose OS + Google IoT Core example

#1

When I try to repeat [https://mongoose-os.com/docs/mongoose-os/cloud/google.md](http://Mongoose OS + Google IoT Core) example, I have get Stack overflow error on esp_main.c:218.

  1. My goal is: connect to the GCP and send data
  2. My actions are: I am repeated your instruction step by step, after “Reporting state to Google IoT Core” I have get the error at all connection to mqtt server
    esp_main.c:218 Stack overflow! Last cb 0x4026a284, ptrs: 16:0x40283696 -2672:0x4027fc48 -3120:0x4023c4ee -3128:0x4021fc00 -3536:0x40266af5 -3624:0x40266528 -4048:0x40100dcb -4064:0x40100285
  3. The result I see is: here the log:
    [Mar  7 13:19:18.973] esp_main.c:165          test 1.0 (20210307-100028)
    [Mar  7 13:19:18.976] esp_main.c:167          Mongoose OS 2.19.1 (20210307-100027/2.19.1-gd52032f) sp 0x3ffffe80
    [Mar  7 13:19:18.985] esp_main.c:169          CPU: ESP8266EX, 160 MHz, RAM: 51768 total, 48700 free
    [Mar  7 13:19:18.993] esp_main.c:173          SDK 3.0.5-dev(52383f9); flash: 4M
    [Mar  7 13:19:18.998] esp_exc.c:235           Reset cause: 6 (sys reset)
    [Mar  7 13:19:19.002] mongoose.c:15676        Mongoose 6.18, LwIP 2.1.2
    [Mar  7 13:19:19.007] mongoose.c:4938         mbed TLS 2.16.6-cesanta1
    [Mar  7 13:19:19.010] mgos_vfs_dev.c:72       sfl0: sysflash (), size 4194304
    [Mar  7 13:19:19.018] mgos_vfs_dev.c:72       root: part ({"dev": "sfl0", "offset": 32768, "size": 262144}), size 262144
    [Mar  7 13:19:19.026] mgos_vfs.c:173          /: SPIFFS @ root, opts {"bs":4096,"ps":256,"es":4096}
    [Mar  7 13:19:19.089] mgos_vfs.c:344          /: size 233681, used: 137297, free: 96384
    [Mar  7 13:19:19.201] mgos_sys_config.c:232   Loading conf9.json
    [Mar  7 13:19:19.207] mgos_sys_config.c:368   MAC: 4a:3f:da:49:41:68
    [Mar  7 13:19:19.210] mgos_sys_config.c:376   WDT: 30 seconds
    [Mar  7 13:19:19.216] mgos_i2c_gpio_maste:248 I2C GPIO init ok (SDA: 12, SCL: 14, freq: 100000)
    [Mar  7 13:19:19.223] mgos_ota_shadow_lib:116 OTA over shadow initialised
    [Mar  7 13:19:19.225] esp_main.c:145          SDK: bcn 0
    [Mar  7 13:19:19.229] esp_main.c:145          SDK: del if1
    [Mar  7 13:19:19.232] esp_main.c:145          SDK: usl
    [Mar  7 13:19:19.235] esp_main.c:145          SDK: mode : null
    [Mar  7 13:19:19.243] mgos_wifi.c:88          WiFi STA: Using config 0 (HG520)
    [Mar  7 13:19:19.246] mgos_wifi.c:468         WiFi mode: STA
    [Mar  7 13:19:19.249] esp_wifi.c:118          WiFi mode: STA
    [Mar  7 13:19:19.252] esp_main.c:145          SDK: mode : sta(48:3f:da:49:41:68)
    [Mar  7 13:19:19.258] esp_main.c:145          SDK: add if0
    [Mar  7 13:19:19.262] esp_main.c:145          SDK: sleep disable
    [Mar  7 13:19:19.264] mgos_wifi.c:270         WiFi STA: Connecting to HG520
    [Mar  7 13:19:19.272] mgos_http_server.c:361  HTTP server started on [80]
    [Mar  7 13:19:19.288] mgos_gcp.c:369          GCP client for home-stolve/europe-west1/home-stolve-devices-registry/esp8266_494168, EC key in gcp-esp8266_494168.key.pem
    [Mar  7 13:19:19.301] mgos_provision_btn.c:87 Factory reset button: pin 0, pull up, hold_ms 0 (hold on boot)
    [Mar  7 13:19:19.320] mgos_provision_stat:120 Max state: 3
    [Mar  7 13:19:19.324] mgos_rpc_channel_ua:313 0x3fff19bc UART0
    [Mar  7 13:19:19.331] mgos_init.c:33          Init done, RAM: 51768 total, 40976 free, 40984 min free
    [Mar  7 13:19:19.568] esp_main.c:218          Stack overflow! Last cb 0x4026700c, ptrs: -960:0x401055c7 -1088:0x40101cec -1184:0x40101cec -1256:0x4021fc00 -1568:0x40101cec -1632:0x40101cec -1728:0x40101cec -1800:0x4021fc00 -2112:0x40101cec -2176:0x40101cec -2272:0x40101cec -2344:0x402
    [Mar  7 13:19:19.592] mgos_mongoose.c:66      New heap free LWM: 33480
    [Mar  7 13:19:19.597] mgos_ota_core.c:1329    UID: 034ee920e393d6b5, license: none
    [Mar  7 13:19:19.602] mgos_net.c:86           WiFi STA: connecting
    [Mar  7 13:19:19.606] mgos_provision_state:44 Current state: 0 -> 1
    [Mar  7 13:19:22.313] esp_main.c:145          SDK: scandone
    [Mar  7 13:19:23.200] esp_main.c:145          SDK: state: 0 -> 2 (b0)
    [Mar  7 13:19:23.216] /devices/esp8266_494168/state -> {"total":51768,"free":37496} 
    [Mar  7 13:19:23.232] esp_main.c:145          SDK: state: 2 -> 3 (0)
    [Mar  7 13:19:23.238] esp_main.c:145          SDK: state: 3 -> 5 (10)
    [Mar  7 13:19:23.240] esp_main.c:145          SDK: add 0
    [Mar  7 13:19:23.244] esp_main.c:145          SDK: aid 8
    [Mar  7 13:19:23.246] esp_main.c:145          SDK: cnt 
    [Mar  7 13:19:23.267] esp_main.c:145          SDK: 
    [Mar  7 13:19:23.267] esp_main.c:145          SDK: connected with HG520, channel 11
    [Mar  7 13:19:23.274] esp_main.c:145          SDK: dhcp client start...
    [Mar  7 13:19:23.283] mgos_wifi.c:133         WiFi STA: Connected, BSSID 64:ee:b7:fc:d7:59 ch 11 RSSI -68
    [Mar  7 13:19:23.289] mgos_net.c:90           WiFi STA: connected
    [Mar  7 13:19:23.821] esp_main.c:145          SDK: ip:192.168.1.82,mask:255.255.255.0,gw:192.168.1.254
    [Mar  7 13:19:23.829] mgos_net.c:101          WiFi STA: ready, IP 192.168.1.82, GW 192.168.1.254, DNS 192.168.1.254
    [Mar  7 13:19:23.836] mgos_provision_state:44 Current state: 1 -> 2
    [Mar  7 13:19:23.842] mgos_mqtt_conn.c:549    MQTT0 connecting after 2081 ms
    [Mar  7 13:19:24.890] mgos_sntp.c:96          SNTP query to time.google.com
    [Mar  7 13:19:24.932] mgos_sntp.c:58          SNTP reply from 216.239.35.8: time 1615112363.262196, local 6.089237, delta 1615112357.172959
    [Mar  7 13:19:25.572] /devices/esp8266_494168/state -> {"total":51768,"free":36396} 
    [Mar  7 13:19:25.930] mgos_mqtt_conn.c:471    MQTT0 connecting to mqtt.2030.ltsapis.goog:8883
    [Mar  7 13:19:25.938] mgos_mongoose.c:66      New heap free LWM: 32632
    [Mar  7 13:19:25.946] mgos_mongoose.c:66      New heap free LWM: 31608
    [Mar  7 13:19:25.957] mgos_mongoose.c:66      New heap free LWM: 31088
    [Mar  7 13:19:26.066] mongoose.c:4912         0x3fff23ec ciphersuite: TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
    [Mar  7 13:19:26.074] mgos_mongoose.c:66      New heap free LWM: 30088
    [Mar  7 13:19:26.100] SW ECDSA verify curve 3 hash_len 32 sig_len 71
    [Mar  7 13:19:26.747] SW ECDSA verify curve 3 hash_len 32 sig_len 72
    [Mar  7 13:19:27.393] SW ECDSA verify curve 3 hash_len 32 sig_len 71
    [Mar  7 13:19:28.660] mgos_mongoose.c:66      New heap free LWM: 20232
    [Mar  7 13:19:28.664] esp_main.c:218          Stack overflow! Last cb 0x4026a284, ptrs: 64:0x401055c7 8:0x4010599e -2672:0x4027fc48 -3128:0x4021fc00 -3536:0x40266af5 -3624:0x40266528 -4048:0x40100dcb -4064:0x40100285
    [Mar  7 13:19:28.697] /devices/esp8266_494168/state -> {"total":51768,"free":27564} 
    [Mar  7 13:19:28.741] mgos_mqtt_conn.c:229    MQTT0 TCP connect ok (0)
    [Mar  7 13:19:29.082] esp_main.c:218          Stack overflow! Last cb 0x4026a284, ptrs: 112:0x401055c7 56:0x4010599e 32:0x401055c7 -24:0x4010599e -64:0x40272cb1 -2040:0x4021fc00 -3128:0x4021fc00 -3536:0x40266af5 -3728:0x4026bc04 -4048:0x40100dcb -4064:0x40100285
    [Mar  7 13:19:31.571] /devices/esp8266_494168/state -> {"total":51768,"free":32892} 
    [Mar  7 13:19:31.960] mgos_mqtt_conn.c:273    MQTT0 CONNACK 0
    [Mar  7 13:19:31.963] mgos_mqtt_conn.c:211    MQTT0 sub /devices/esp8266_494168/commands/# @ 1
    [Mar  7 13:19:32.024] mgos_provision_state:44 Current state: 2 -> 3
    [Mar  7 13:19:32.092] mgos_mqtt_conn.c:256    MQTT0 Disconnect
    [Mar  7 13:19:32.095] mgos_mqtt_conn.c:549    MQTT0 connecting after 2112 ms
    [Mar  7 13:19:33.249] esp_main.c:145          SDK: pm open,type:0 0
    [Mar  7 13:19:34.212] mgos_mqtt_conn.c:471    MQTT0 connecting to mqtt.2030.ltsapis.goog:8883
    [Mar  7 13:19:34.333] mongoose.c:4912         0x3fff23ec ciphersuite: TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
    [Mar  7 13:19:34.363] SW ECDSA verify curve 3 hash_len 32 sig_len 71
    [Mar  7 13:19:35.011] SW ECDSA verify curve 3 hash_len 32 sig_len 72
    [Mar  7 13:19:35.663] SW ECDSA verify curve 3 hash_len 32 sig_len 70
    [Mar  7 13:19:36.930] esp_main.c:218          Stack overflow! Last cb 0x4026a284, ptrs: 64:0x40282fe9 -2672:0x4027fc48 -3120:0x4023c4ee -3128:0x4021fc00 -3536:0x40266af5 -3624:0x40266528 -4048:0x40100dcb -4064:0x40100285
    [Mar  7 13:19:36.962] /devices/esp8266_494168/state -> {"total":51768,"free":27456} 
    [Mar  7 13:19:37.003] mgos_mqtt_conn.c:229    MQTT0 TCP connect ok (0)
    [Mar  7 13:19:37.344] esp_main.c:218          Stack overflow! Last cb 0x4026a284, ptrs: 16:0x40282fe9 -96:0x402675ba -128:0x401055c7 -184:0x4010599e -272:0x401053ce -304:0x40281bec -312:0x4010599e -432:0x40282a5e -2040:0x4021fc00 -2112:0x4026b81d -3128:0x4021fc00 -3536:0x40266af5 -372
    [Mar  7 13:19:37.444] mgos_mqtt_conn.c:273    MQTT0 CONNACK 0
    [Mar  7 13:19:37.450] mgos_mqtt_conn.c:211    MQTT0 sub /devices/esp8266_494168/commands/# @ 1
    [Mar  7 13:19:37.572] /devices/esp8266_494168/state -> {"total":51768,"free":32944} 
    [Mar  7 13:19:37.589] mgos_mqtt_conn.c:256    MQTT0 Disconnect
    [Mar  7 13:19:37.592] mgos_mqtt_conn.c:549    MQTT0 connecting after 1853 ms
    [Mar  7 13:19:39.453] mgos_mqtt_conn.c:471    MQTT0 connecting to mqtt.2030.ltsapis.goog:8883
    [Mar  7 13:19:39.577] mongoose.c:4912         0x3fff23ec ciphersuite: TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
    [Mar  7 13:19:39.608] SW ECDSA verify curve 3 hash_len 32 sig_len 71
  1. My expectation & question is: Early (a year ago) I have not get this error. Where is the reason of it?
#2

Sometimes a bug is lurking happy unnoticed for years until a change in other place causes it to surface.
If you did not modify the example, it should work.
Since 2.19.x is freshly out, I suggest you try the former 2.18.0 and see if it works.

#3

Thank you for answer. Script work well on 2.18.0 and show esp_main.c:218 Stack overflow! (but work too) with 2.19