ESP32 crashes when using rom\miniz decompression function

dandydan51
Posts: 5
Joined: Sat Aug 26, 2023 9:34 pm

ESP32 crashes when using rom\miniz decompression function

Postby dandydan51 » Sat Aug 26, 2023 10:24 pm

I am testing the use of the miniz library that is part of ESP32 Framework. This test should decompress the src_buf data and return uncomp_size = either -1 (failed) or 1440 (success).

This sketch compiles on Arduino IDE 2.1.1 and loads to the board. When it runs, the ESP32 crashes with the messages below the code.

Not sure what the problem is. Any help would be appreciated. Please let me know if it works on your boards or not.

I have used zlib utilities on my computer to decompress this same data and it works perfectly.

Thank you.

Code: Select all

#include <rom\miniz.h>
//Global variables and buffers
size_t uncomp_size = 0;
char out_buf[1440];
size_t out_buf_len = sizeof(out_buf);
char src_buf[240] = {
  0x78, 0x01, 0xED, 0x52, 0xDB, 0x0D, 0xC3, 0x20, 0x10, 0xCB, 0x16, 0x6C, 0xD1, 0x31, 0x6E, 0x8B,
  0x6E, 0x71, 0x5B, 0x74, 0x0B, 0xB6, 0xC8, 0x18, 0x6C, 0xD1, 0x2D, 0xA8, 0x7D, 0x26, 0x88, 0x94,
  0x46, 0x4A, 0xFA, 0x9D, 0x13, 0x42, 0xE1, 0x1E, 0xB6, 0x31, 0x59, 0x96, 0x3B, 0x6E, 0x07, 0xFE,
  0x77, 0xA0, 0x22, 0x72, 0xAE, 0x29, 0xBD, 0x7C, 0x79, 0x27, 0xE2, 0x60, 0xAF, 0x66, 0x5C, 0x29,
  0x3D, 0xCA, 0x0E, 0x79, 0xB5, 0x28, 0x45, 0x3F, 0xBE, 0x51, 0x45, 0x73, 0xEB, 0x17, 0x8E, 0x19,
  0x8F, 0x31, 0x88, 0xBD, 0xBA, 0x73, 0x99, 0x3D, 0xF3, 0x84, 0x83, 0xFC, 0xC6, 0x2B, 0x52, 0x0E,
  0xBA, 0xAB, 0x4F, 0x25, 0x1C, 0xA1, 0x8A, 0x08, 0xA5, 0x70, 0xE5, 0x0C, 0xD2, 0x1E, 0xC0, 0xA4,
  0xC8, 0x42, 0x89, 0xEC, 0x37, 0xA3, 0x3C, 0x31, 0x46, 0x92, 0x79, 0x4C, 0x05, 0x11, 0x4B, 0xE8,
  0x51, 0x94, 0x02, 0xAE, 0x1E, 0x0D, 0xA7, 0xD6, 0x86, 0x13, 0x56, 0x34, 0x9C, 0x48, 0xAA, 0xB3,
  0x8D, 0xE3, 0x52, 0x63, 0xD2, 0x0C, 0x0A, 0xE1, 0x83, 0xAC, 0x90, 0x98, 0xD6, 0x0F, 0x6A, 0xC8,
  0x8B, 0xE8, 0x5C, 0xA4, 0x10, 0x91, 0x0D, 0x37, 0x41, 0xD2, 0x1D, 0x32, 0x7E, 0xE3, 0x84, 0x4B,
  0x33, 0x4E, 0x57, 0xB5, 0x03, 0x07, 0x69, 0x4A, 0xB8, 0xAC, 0xAC, 0x18, 0x4B, 0xA4, 0xDE, 0x6C,
  0xF9, 0xCA, 0xCF, 0x25, 0xD0, 0xC1, 0xA2, 0x43, 0x9C, 0xBC, 0x7F, 0xCE, 0x19, 0x6E, 0xC8, 0xE8,
  0x69, 0x64, 0xC5, 0x90, 0xBE, 0xFC, 0xC9, 0x17, 0xD1, 0x6F, 0x39, 0xF8, 0x7F, 0x19, 0x25, 0x06,
  0xF8, 0x57, 0x1C, 0x5B, 0x71, 0x12, 0x93, 0x2F, 0x72, 0x02, 0xE7, 0x03, 0xC8, 0xD0, 0xE5, 0xCE
};
size_t src_buf_len = sizeof(src_buf);

void setup() {
  Serial.begin(115200);
  delay(10000);
  //    from miniz.h  size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
  uncomp_size = tinfl_decompress_mem_to_mem((void *)out_buf, out_buf_len, (const void *)src_buf, src_buf_len, TINFL_FLAG_PARSE_ZLIB_HEADER);
  Serial.println((int)uncomp_size);
}

void loop() {
  // put your main code here, to run repeatedly:
}
Here are the messages I get when I run this sketch on my ESP32 Dev board (4MB):

mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:13260
load:0x40080400,len:3028
entry 0x400805e4
Guru Meditation Error: Core 1 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (loopTask)
Core 1 register dump:
PC : 0x4000c46c PS : 0x00060836 A0 : 0x8005f4f0 A1 : 0x3ffc2bc0
A2 : 0x3ffc3650 A3 : 0x00000000 A4 : 0x00000480 A5 : 0x3ffc38e0
A6 : 0x3ffbdc5c A7 : 0x00000048 A8 : 0x04040404 A9 : 0x05030303
A10 : 0x3ff000e0 A11 : 0x00000002 A12 : 0x3ffbdd68 A13 : 0x00000001
A14 : 0x007bf3e8 A15 : 0x003fffff SAR : 0x0000001a EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x4000c46c LEND : 0x4000c477 LCOUNT : 0x0000001e


Backtrace: 0x4000c469:0x3ffc2bc0 0x4005f4ed:0x3ffc2bd0 0x40060082:0x3ffc2ce0 0x400d135d:0x3ffc5810 0x400d24a6:0x3ffc5840




ELF file SHA256: 251ede62fe45f1f4

E (10114) esp_core_dump_flash: Core dump flash config is corrupted! CRC=0x7bd5c66f instead of 0x0
Rebooting...

boarchuz
Posts: 567
Joined: Tue Aug 21, 2018 5:28 am

Re: ESP32 crashes when using rom\miniz decompression function

Postby boarchuz » Sun Aug 27, 2023 4:28 am

Debug exception reason: Stack canary watchpoint triggered (loopTask)
You'll need to increase loopTask's stack size. This is the task that Arduino creates to run your code, ie. setup() and loop(). I don't know if there's an easy way to do that, so it might be easiest (at least for the purposes of testing) to create a new task in setup() to handle the decompression.

Remember to decode your backtrace in future too, it makes it much easier to see where things are going wrong.

dandydan51
Posts: 5
Joined: Sat Aug 26, 2023 9:34 pm

Re: ESP32 crashes when using rom\miniz decompression function

Postby dandydan51 » Sun Aug 27, 2023 4:08 pm

Solved!!

SET_LOOP_TASK_STACK_SIZE( 16*1024 ); // 16KB
void setup() {

Thank you. I spent two weeks trying to crack this.

Who is online

Users browsing this forum: No registered users and 132 guests