Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Chunked Response - Guru Meditation Error: Core 1 panic'ed (Interrupt wdt timeout on CPU1) #1002

Closed
@Stumblor

Description

@Stumblor

Hi - firstly thanks so much for all your hard work on this great library. I've been using it for a while (both on the ESP8266 and the ESP32) and have been using beginChunkedResponse to serve large gzipped html pages (+500kb of minified html, css and js, and then gzipped).

When getting this setup on a new project last night (ESP32), I noticed that these requests were rebooting the device - at around the 66% mark.

Guru Meditation Error: Core  1 panic'ed (Interrupt wdt timeout on CPU1)
Core 1 register dump:
PC      : 0x4000c271  PS      : 0x00060034  A0      : 0x8008a3ac  A1      : 0x3ffd08f0  
A2      : 0x3ffccc78  A3      : 0x3f42851c  A4      : 0x00000014  A5      : 0x3ffc0330  
A6      : 0x3ffc0378  A7      : 0x00000001  A8      : 0x00000001  A9      : 0x3f42851d  
A10     : 0x000000a5  A11     : 0x00000000  A12     : 0x8008af63  A13     : 0x3ffc0300  
A14     : 0x00000008  A15     : 0x00000001  SAR     : 0x00000015  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x4000c349  LEND    : 0x4000c36b  LCOUNT  : 0x00000079  

ELF file SHA256: 0000000000000000

Backtrace: 0x4000c271:0x3ffd08f0 0x4008a3a9:0x3ffd0910 0x4008bf58:0x3ffd0930 0x4008bf0e:0x00000001
  #0  0x4000c271:0x3ffd08f0 in ?? ??:0
  #1  0x4008a3a9:0x3ffd0910 in vTaskSwitchContext at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:3507
  #2  0x4008bf58:0x3ffd0930 in _frxt_dispatch at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portasm.S:406
  #3  0x4008bf0e:0x00000001 in _frxt_int_exit at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portasm.S:206

Core 0 register dump:
PC      : 0x4016e1fe  PS      : 0x00060634  A0      : 0x800f4a75  A1      : 0x3ffbc1c0  
A2      : 0x00000000  A3      : 0x00000001  A4      : 0x800899cc  A5      : 0x3ffb3cb0  
A6      : 0x00000000  A7      : 0x3ffbbec0  A8      : 0x800f3906  A9      : 0x3ffbc190  
A10     : 0x00000000  A11     : 0x00000001  A12     : 0x800899cc  A13     : 0x3ffbc0c0  
A14     : 0x00000000  A15     : 0x3ffbbec0  SAR     : 0x00000000  EXCCAUSE: 0x00000006  
EXCVADDR: 0x00000000  LBEG    : 0x00000000  LEND    : 0x00000000  LCOUNT  : 0x00000000  

ELF file SHA256: 0000000000000000

Backtrace: 0x4016e1fe:0x3ffbc1c0 0x400f4a72:0x3ffbc1e0 0x4008af51:0x3ffbc200 0x400897ba:0x3ffbc220
  #0  0x4016e1fe:0x3ffbc1c0 in esp_pm_impl_waiti at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/pm_esp32.c:492
  #1  0x400f4a72:0x3ffbc1e0 in esp_vApplicationIdleHook at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/freertos_hooks.c:108
  #2  0x4008af51:0x3ffbc200 in prvIdleTask at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c:3507
  #3  0x400897ba:0x3ffbc220 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)

So I started stripping out everything in my project, all the interupts etc - all the things you would think of that would typically clash and cause this type of reset. I'm now down to a really simple example (essentially the one taken from the README, but using chunked response) and still getting the error.

My code:

#include <Arduino.h>
#include "../lib/html.h"
#include "AsyncTCP.h"
#include "ESPAsyncWebServer.h"

AsyncWebServer server(80);

void setup(){
  Serial.begin(115200);
  WiFi.mode(WIFI_AP);
  const char* wifi_name = "Testing";
  WiFi.softAP(wifi_name);

  IPAddress myIP = WiFi.softAPIP();
  Serial.println("Server started: " + (String)wifi_name);
  Serial.print("IP: ");
  Serial.println(myIP);

  server.on("/", [](AsyncWebServerRequest *request) { 

      // Chunked response, we calculate the chunks based on free heap (in multiples of 32)
      // This is necessary when a TLS connection is open since it sucks too much memory
      size_t max = (ESP.getFreeHeap() / 3) & 0xFFE0;
      Serial.println("Request Received. Memory: " + (String)max + "  Pagesize: " + (String) + wifi_html_length);

      AsyncWebServerResponse *response = request->beginChunkedResponse("text/html", [max](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {

          // Get the chunk based on the index and maxLen
          size_t len = wifi_html_length - index;
          if (len > maxLen) len = maxLen;
          if (len > max) len = max;
          if (len > 0) memcpy_P(buffer, wifi_html_gzip + index, len);

          Serial.printf(PSTR("[WEB] Sending %d%%%% (max chunk size: %4d)\r"), int(100 * index / wifi_html_length), max);
          if (len == 0) Serial.printf(PSTR("\n"));

          // Return the actual length of the chunk (0 for end of file)
          return len;

      });

  response->addHeader("Content-Encoding", "gzip");
  //response->addHeader("Last-Modified", _last_modified);
  request->send(response);
  });

  server.begin();
}

void loop() {
  
}

platformio.ini

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
board_upload.speed = 921600
monitor_speed = 115200
monitor_filters = esp32_exception_decoder
lib_deps = 
	me-no-dev/ESP Async WebServer@^1.2.3

html.c (cut down)

/* wifi.html - GZIPPED */

  const uint32_t wifi_html_length = 503560;
  const uint8_t wifi_html_gzip[] PROGMEM = {
    0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x13, 0xec, 0xbd, 0x6b, 0x77, 0x1b, 0x37,
  0x92, 0x30, 0xfc, 0x7d, 0x7f, 0x05, 0x9f, 0xe4, 0xcc, 0x49, 0xb4, 0x96, 0xe8, 0x6e, 0xde, 0x29,
  0xce, 0xf8, 0xac, 0x14, 0x3b, 0x8e, 0x33, 0x49, 0x26, 0x9e, 0x99, 0x64, 0xc6, 0xd9, 0x77, 0x3e,
  0x34, 0xc9, 0xa6, 0xc4, 0x84, 0x12, 0xf5, 0x90, 0x94, 0x65, 0x45, 0x47, 0xfb, 0xdb, 0x9f, 0xc6,
  0xa5, 0xbb, 0x71, 0xa9, 0x2a, 0x14, 0x9a, 0xb4, 0x9d, 0xec, 0x3b, 0x56, 0x62, 0xab, 0x81, 0x02,
  0xea, 0x82, 0xaa, 0x02, 0x50, 0x8d, 0x46, 0xfd, 0xf1, 0x2a, 0xdf, 0x65, 0xad, 0xeb, 0xec, 0x2a,
  0xff, 0xd3, 0x27, 0x6f, 0x97, 0xf9, 0xdd, 0xcd, 0x7a, 0xb3, 0xfb, 0xa4, 0x35, 0x5b, 0x5f, 0xef,
  0xf2, 0xeb, 0xdd, 0x9f, 0x3e, 0xb9, 0x5b, 0xce, 0x77, 0x97, 0x7f, 0x9a, 0xe7, 0x6f, 0x97, 0xb3
...
  0xcf, 0xde, 0x04, 0x26, 0x09, 0x00
  };

If I remove one of the larger css files, the request completes, so there seems to be some kind of limit that I'm hitting, although I have served larger pages than this one in the past.

I've tried turning off WDT interrupt timeouts (just to test!) but these don't seem to make any difference.

  //rtc_wdt_protect_off(); 
  //rtc_wdt_disable();
  //disableCore0WDT();
  //disableCore1WDT();
  //disableLoopWDT();

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions