How to prevent dumping core on ESP32?

Hello,

We would like to restart the app ASAP if it crashes. Now it first dumps a core and it takes a long.

This doesn’t work - the core is still dumped (to UART):

build_vars:
  ESP_IDF_SDKCONFIG_OPTS: >
    ${build_vars.ESP_IDF_SDKCONFIG_OPTS}
    CONFIG_ESP32_ENABLE_COREDUMP_TO_UART=
    CONFIG_ESP32_ENABLE_COREDUMP=n

What is the correct way to do it?

Thanks in advance.

I believe the option " --catch-core-dumps false" is what you are looking for. See “mos help --full”.

1 Like
        ESP_IDF_SDKCONFIG_OPTS: >
          ${build_vars.ESP_IDF_SDKCONFIG_OPTS}
          CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y
[May  1 11:28:44.376] Guru Meditation Error: Core  0 panic'ed (IntegerDivideByZero). Exception was unhandled.
[May  1 11:28:44.376] Core 0 register dump:
[May  1 11:28:44.376] PC      : 0x400e5c34  PS      : 0x00060a30  A0      : 0x800e2fbd  A1      : 0x3ffb4ec0  
[May  1 11:28:44.376] A2      : 0x3ffb0a88  A3      : 0x3ffc8fdc  A4      : 0x00000000  A5      : 0x4039443f  
[May  1 11:28:44.376] A6      : 0x00000000  A7      : 0x40000000  A8      : 0x00000000  A9      : 0x00000000  
[May  1 11:28:44.376] A10     : 0x3ffb0a84  A11     : 0x3f405863  A12     : 0x3ffb2f2c  A13     : 0x00000000  
[May  1 11:28:44.376] A14     : 0x3ffb4f50  A15     : 0x00000001  SAR     : 0x00000013  EXCCAUSE: 0x00000006  
[May  1 11:28:44.376] EXCVADDR: 0x00000000  LBEG    : 0x400029ac  LEND    : 0x400029cb  LCOUNT  : 0x00000000  
[May  1 11:28:44.376] 
[May  1 11:28:44.376] Backtrace: 0x400e5c34 0x400e2fba 0x4016a1f2 0x4016b6a2 0x4016ddd0 0x4017e6c1 0x401661fd 0x4008395e 0x40083b25
[May  1 11:28:44.376] Rebooting...
1 Like

Thanks @nliviu, I’ll try it. I wonder why CONFIG_ESP32_ENABLE_COREDUMP=n doesn’t also have this effect.

Select place to store core dump: flash, uart or none (to disable core dumps generation).

1 Like

Where to mention this code ??

  • My heap is getting full that’s why core dump is happening … Is their way to prevent heap from getting full??

  • I am just data from gps module to aws cloud … so I need my esp32 to work continuously but it tends to work for 40 min and then dump core and restarts … How to prevent that and make esp32 work continuously .

Are you still using this library?
It has memory leaks.

Yes … I am using the library
Is their any other option??
Memory Leaks??

It allocates memory here and never frees it.

Can I free the memory in my code or What changes can I make in the library??
I am new to mongoose so I don’t know it in detail…

No. This issue is not related to Mongoose OS. It’s basic C programming.

BTW, did the library compile successfully? Because it declares void mgos_gps_get_location(); and defines char *mgos_get_location(). Or are you using mJS?

It compiled successfully for esp32

Maybe it compiles ok, but can’t be used in C.

@qwertyui Modify the body of mgos_get_location

  static char buf[100];
  struct json_out out = JSON_OUT_BUF(buf, sizeof(buf));

  float lat = minmea_tocoord(&lastFrame.latitude);
  float lon = minmea_tocoord(&lastFrame.longitude);
  float speed = minmea_tofloat(&lastFrame.speed);

  json_printf(&out, "{lat: \"%f\", lon: \"%f\", sp: \"%f\"}", lat, lon, speed);
  /* make the buffer zero terminated */
  strcat(buf, "");

  return buf;