Abort call while running a code using Free RTOS with esp32

hi i’m wrtiting a code for a device that uses esp32 wroom it gets some numbers and sends them to a server i use arduino platform with platformio .Free RTOS is used in this code. When the code reaches to the section that is for converting the strings which are read from SPIFFS to numbers it crashes and sends this message in serial “abort() was called at PC 0x40158d07 on core 0” and then resets the esp32.
i can’t bring the whole code here because it too long but i can show some faulty parts and error and debug messages here.
i tried to debug the code and this is what i’m getting

Backtrace: 0x400838d1:0x3fff0c90 0x4008dbad:0x3fff0cb0 0x40093205:0x3fff0cd0 0x40158d07:0x3fff0d50 0x40158d4e:0x3fff0d70 0x40158caf:0x3fff0d90 0x4015a15f:0x3fff0db0 0x400d32f9:0x3fff0dd0 0x400d4d61:0x3fff0e00 0x400d963f:0x3fff0e30

  #0  0x400838d1:0x3fff0c90 in panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
  #1  0x4008dbad:0x3fff0cb0 in esp_system_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/esp_system.c:128
  #2  0x40093205:0x3fff0cd0 in abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/newlib/abort.c:46
  #3  0x40158d07:0x3fff0d50 in __cxxabiv1::__terminate(void (*)()) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:47
  #4  0x40158d4e:0x3fff0d70 in std::terminate() at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:57       
  #5  0x40158caf:0x3fff0d90 in __cxa_throw at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/libsupc++/eh_throw.cc:95
  #6  0x4015a15f:0x3fff0db0 in std::__throw_invalid_argument(char const*) at /builds/idf/crosstool-NG/.build/HOST-x86_64-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/src/c++11/functexcept.cc:74 (discriminator 2)
  #7  0x400d32f9:0x3fff0dd0 in unsigned long __gnu_cxx::__stoa<unsigned long, unsigned long, char, int>(unsigned long (*)(char const*, char**, int), char const*, char const*, unsigned int*, int) at c:\users\research7\.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\ext/string_conversions.h:83
  #8  0x400d4d61:0x3fff0e00 in std::stoul(std::string const&, unsigned int*, int) at c:\users\research7\.platformio\packages\toolchain-xtensa-esp32\xtensa-esp32-elf\include\c++\8.4.0\bits/basic_string.h:6421
      (inlined by) convert_SPIFFS_read_string_to_number() at src/main.cpp:1702
  #9  0x400d963f:0x3fff0e30 in SendDatahandle(void*) at src/main.cpp:731
ELF file SHA256: b7d374a94b63a11e

the function convert_SPIFFS_read_string_to_number() is as follows :

void convert_SPIFFS_read_string_to_number(void)

    string mac_send_spiffs_string(mac_send_vector_spiffs.begin(), mac_send_vector_spiffs.end());
    for (int i = 0; i < mac_send_vector_spiffs.size(); i++)
      printf("mac send vector is %c", mac_send_vector_spiffs[i]);
    Serial.printf("mac send spiffs string is %s", mac_send_spiffs_string.c_str());
    string entrance_spiffs_string(entrance_char_vector_spiffs.begin(), entrance_char_vector_spiffs.end());
    string exit_spiffs_string(exit_char_vector_spiffs.begin(), exit_char_vector_spiffs.end());
     for (int i = 0; i < exit_char_vector_spiffs.size(); i++)
      printf("exit char vector spiffs is %c", exit_char_vector_spiffs[i]);
    mac_send_input_mac = stoi(mac_send_spiffs_string);
    Serial.printf("mac_send_input_mac is %i", mac_send_input_mac);
    mac_send_input_entrance = stoul(entrance_spiffs_string);
    Serial.printf("mac send input entrance is %lu",mac_send_input_entrance);
    mac_send_input_exit = stoul(exit_spiffs_string);
    Serial.printf("mac send input exit is %lu",mac_send_input_exit);

and this is part of the code that calls this function :

                SendTo_Server_Status mac_send_status_in_success_clause;
                mac_send_status_in_success_clause = MAC_SEND_TO_SERVER(mac_send_input_entrance_vect[mac_index], mac_send_input_exit_vect[mac_index], mac_send_input_mac_vect[mac_index]);
                if (mac_send_status_in_success_clause == DATA_SEND_SUCCESS)
                  SPIFFS_REMOVE_EPOCH(enter_date, mac_index);
                  SPIFFS_REMOVE_EPOCH(exit_date, mac_index);
                  SPIFFS_SUCCESS = 0;
                  NEED_SPIFFS_READING = 0;

what might cause this problem ? is it related to stack overflow ? or heap memory? or something else ? thanks in advanced

Well if stoul aka “String to unsigned long” is throwing a invalid_argument error, then you’re giving it something that’s not a number. Have you made sure to print out the arguments to the function (and Serial.flush(); after printing to make sure that you see the output before it crashes) to check if all input is good?

thanks for your reply. yes i checked the input and the code had some mistakes and i corrected them but i still get this abort error. now the last thing it prints out is from SPIFF_READ_MAC function but the backtrace refers to the next function as shown above. i’m confused ! :exploding_head: