Stumped. Stack smashing protect failure

themagicm
Posts: 10
Joined: Tue Mar 28, 2023 2:27 am

Stumped. Stack smashing protect failure

Postby themagicm » Tue Oct 01, 2024 2:20 am

I am totally stumped as to how to track this down.

The only time it happens is when I save a value every 30 seconds using preferences.h.

Code: Select all

void dothis(double value)
{
 
 
    // Save the odometer value using Preferences
    preferences.begin("gps", false);                  // Open preferences in read-write mode
    preferences.putDouble("distance", value); // Store odometer value
    preferences.end();                                // Close preferences
 
  }
I basically read data from my CAN network and every 30 seconds call dothis. After a while I get stack smashing but I am totally stumped since it doesnt really say much.


this is the error in PlatformIO:

Code: Select all

abort() was called at PC 0x4012202b on core 1
Backtrace: 0x40083dc1:0x3ffbf59c |<-CORRUPTED

Then I run this to get some info on it:

Code: Select all

./xtensa-esp32-elf/esp-12.2.0_20230208/xtensa-esp32-elf/bin/xtensa-esp32-elf-addr2line -pfiaC -e firmware.elf 0x40083e1d 0x3ffbf56c
and then I get this which doesnt mean anything to me:

Code: Select all

0x40083e1d: panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:408
0x3ffbf56c: port_IntStack at ??:?
I am totally stumped. This is a simplified version of what I'm doing. But if I dont save using preferences.h (I even tried littlefs which crashes also) then it doesnt give me any stack smashing.

lbernstone
Posts: 829
Joined: Mon Jul 22, 2019 3:20 pm

Re: Stumped. Stack smashing protect failure

Postby lbernstone » Tue Oct 01, 2024 2:42 am

Stack smashing means you are running out of stack memory. The corruption error looks more like you are trying to access a variable that has been allocated out of bounds.
Check to make sure you are not allocating huge variables into your stack by using large char arrays. Passing around objects/Strings can also use up all your stack. Pass constants into your function variables.

Who is online

Users browsing this forum: No registered users and 31 guests