Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

ESP32 crashes on startup with dash enabled

I've had dash configured and working fine for weeks, but recently something has changed and it crashes almost immediately on startup:

#0  0x4000c344 in ?? ()
#1  0x40174a8a in mg_strdup_common (nul_terminate=1, s=...)
    at common/mg_str.c:67
#2  mg_strdup_nul (s=...) at common/mg_str.c:83
#3  0x400fe9da in mg_rpc_channel_ws_out_copy_cfg (in=0x3ffc5920)
    at /Users/ant/src/mongoose-experiments/my-app/deps/rpc-common/src/mg_rpc/mg_rpc_channel_ws.c:375
#4  mg_rpc_channel_ws_out (mgr=0x3ffbb060 <s_mgr>, cfg=0x3ffc5920)
    at /Users/ant/src/mongoose-experiments/my-app/deps/rpc-common/src/mg_rpc/mg_rpc_channel_ws.c:411
#5  0x4017c242 in mgos_dash_init ()
    at /data/srcfs/tmp/publish_src/mos_libs/dash/src/mgos_dash.c:200
#6  0x400faeef in mgos_deps_init ()
    at /Users/ant/src/mongoose-experiments/my-app/build/gen/mgos_deps_init.c:121
#7  0x400e281b in mgos_init () at /mongoose-os/fw/src/mgos_init.c:56
#8  0x400e25d3 in mgos_init2 () at /mongoose-os/fw/src/mgos_hal_freertos.c:195
#9  0x40082d3b in mgos_task (arg=0x0)
    at /mongoose-os/fw/src/mgos_hal_freertos.c:206

The device has WiFi STA correctly configured, and it has dash: { enabled: true, token: "blahblahblah" }

If I set dash.enabled to false the device runs normally.

Comments

  • #3 is actually a few lines earlier than reported because I added some debug in an attempt to diagnose the problem:

         #if MG_ENABLE_SSL
            out->ssl_ca_file = mg_strdup_nul(in->ssl_ca_file);
            out->ssl_client_cert_file = mg_strdup_nul(in->ssl_client_cert_file);
           printf("out %p, in %p\n", out, in);
           /*printf("in->ssl_server_name: (%d) %s\n", in->ssl_server_name.len, in->ssl_server_name.p);*/
           printf("in->ssl_server_name: (%d)\n", in->ssl_server_name.len);
           hex_dump("WS", (uint8_t *)&(in->ssl_server_name), 0, 8);
            out->ssl_server_name = mg_strdup_nul(in->ssl_server_name); // <--- PROBLEM IS HERE
          #endif
    

    The output is:

    [Jun 12 09:59:21.376]
    [Jun 12 09:59:21.383] out 0x3ffcde94, in 0x3ffc5920
    [Jun 12 09:59:21.386] in->ssl_server_name: (60)
    [Jun 12 09:59:21.390]               WS: 0000: 05 00 00 00 3c 00 00 00          : ....<...
    [Jun 12 09:59:21.396]
    

    in->ssl_server_name is a struct mg_str whose .len is 60, and whose .p is a funky 0x00000005, I believe it is the dereference of the latter that causes the problem. It seems this is called from closed-source library code so I am unable to diagnose it any further.

  • antant UK
    edited June 12

    Dumping out the mg_rpc_channel_ws_out_cfg I get:

    [Jun 12 11:03:49.804]
    [Jun 12 11:03:49.804]              WS2: 0000: 74 69 fc 3f 25 00 00 00 94 7d fc 3f 06 00 00 00  : ti ?%... } ?....
    [Jun 12 11:03:49.811]              WS2: 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  : ................
    [Jun 12 11:03:49.821]              WS2: 0020: 05 00 00 00 3c 00 00 00 00 00 00 00 00 00 00 00  : ....<...........
    [Jun 12 11:03:49.830]              WS2: 0030: 00 00 00 00              : ....
    [Jun 12 11:03:49.833]
    

    I'm guessing the 5 and the 60 are meant to be the 'int reconnect_interval_min' and 'int reconnect_interval_max' fields respectively. Did the definition of this struct change recently? I'm guessing an mg_str got added, and the open-source definition of this struct is now out of date with my closed-source definition of this struct...

  • did an rm deps/dash/lib/esp32/libdash.a and a clean rebuild, seems to have fixed it!

  • nliviunliviu Romania

    Can I close this thread?

Sign In or Register to comment.