ESP32 + -Og = Crash
Created by: dyarkovoy
Environment: PlatformIO 4.4.05a (development version) on VSCode ESP32 dev board framework = arduino, espidf
Repro: https://github.com/esp32m/bugs/tree/master/aj-bug
Notes: It may or may not be related to ArduinoJson, as it happens only under very specific conditions:
- v4.0 of the framework-arduinoespressif32
- arduino used as library in esp-idf (framework = arduino, espidf)
- the document is de-serialized from the Arduino Stream (SPIFFS)
- DynamicJsonDocument is created with a small buffer and deserializeJson returns NoMemory
- -DARDUINOJSON_USE_DOUBLE=0 - not strictly necessary, but corrupts the heap faster with this setting
This is what I get when running the code:
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:7016
load:0x40078000,len:14076
load:0x40080400,len:4304
entry 0x400806e8
I (71) boot: Chip Revision: 1
I (72) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot: ESP-IDF HEAD-HASH-NOTFOUND 2nd stage bootloader
I (39) boot: compile time 09:44:08
I (40) boot: Enabling RNG early entropy source...
I (45) boot: SPI Speed : 40MHz
I (49) boot: SPI Mode : DIO
I (53) boot: SPI Flash Size : 4MB
I (58) boot: Partition Table:
I (61) boot: ## Label Usage Type ST Offset Length
I (68) boot: 0 nvs WiFi data 01 02 00009000 00004000
I (76) boot: 1 otadata OTA data 01 00 0000d000 00002000
I (83) boot: 2 phy_init RF data 01 01 0000f000 00001000
I (91) boot: 3 ota_0 OTA app 00 10 00010000 001f0000
I (98) boot: 4 ota_1 OTA app 00 11 00200000 001f0000
I (106) boot: 5 eeprom Unknown data 01 99 003f0000 00001000
I (113) boot: 6 spiffs Unknown data 01 82 003f1000 0000f000
I (121) boot: End of partition table
I (125) boot_comm: chip revision: 1, min. application chip revision: 0
I (132) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x08314 ( 33556) map
I (153) esp_image: segment 1: paddr=0x0001833c vaddr=0x3ffb0000 size=0x0240c ( 9228) load
I (157) esp_image: segment 2: paddr=0x0001a750 vaddr=0x40080000 size=0x00400 ( 1024) load
I (162) esp_image: segment 3: paddr=0x0001ab58 vaddr=0x40080400 size=0x054b8 ( 21688) load
I (179) esp_image: segment 4: paddr=0x00020018 vaddr=0x400d0018 size=0x20794 (133012) map
I (227) esp_image: segment 5: paddr=0x000407b4 vaddr=0x400858b8 size=0x050d4 ( 20692) load
I (243) boot: Loaded app from partition at offset 0x10000
I (243) boot: Disabling RNG early entropy source...
I (244) cpu_start: Pro cpu up.
I (247) cpu_start: Application information:
I (252) cpu_start: Project name: aj-bug
I (257) cpu_start: App version: 1
I (261) cpu_start: Compile time: Jul 17 2020 09:43:44
I (267) cpu_start: ELF file SHA256: 361885746a3b8d98...
I (273) cpu_start: ESP-IDF: HEAD-HASH-NOTFOUND
I (279) cpu_start: Starting app cpu, entry point is 0x400814ac
I (266) cpu_start: App cpu up.
I (290) heap_init: Initializing. RAM available for dynamic allocation:
I (297) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (303) heap_init: At 3FFB3538 len 0002CAC8 (178 KiB): DRAM
I (309) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (315) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (322) heap_init: At 4008A98C len 00015674 (85 KiB): IRAM
I (328) cpu_start: Pro cpu start user code
I (347) spi_flash: detected chip: generic
I (347) spi_flash: flash io: dio
I (348) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
trying size 200CORRUPT HEAP: Block 0x73227b38 is outside heap (last valid block 0x3ffb8af0)
heap corrupted aftr calling deserializeJson()
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x4000c789 PS : 0x00060030 A0 : 0x80001d53 A1 : 0x3ffb5a40
A2 : 0x00000000 A3 : 0x40001fec A4 : 0x3ffb4324 A5 : 0x00000001
A6 : 0x3ffb43af A7 : 0x3ffb424c A8 : 0x00060023 A9 : 0x00000001
A10 : 0x00060021 A11 : 0x00060f23 A12 : 0x00060f20 A13 : 0x00000001
A14 : 0x00060f20 A15 : 0xfffffffc SAR : 0x00000000 EXCCAUSE: 0x0000001c
EXCVADDR: 0x0000000d LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
ELF file SHA256: 361885746a3b8d98
Backtrace: 0x4000c786:0x3ffb5a40 0x40001d50:0x3ffb5a60 0x400e0c69:0x3ffb5a80 0x400869b6:0x3ffb5aa0 0x4008763a:0x3ffb5ac0 0x4008764f:0x3ffb5ae0 0x40085ad9:0x3ffb5b00
#0 0x4000c786:0x3ffb5a40 in ?? ??:0
#1 0x40001d50:0x3ffb5a60 in ?? ??:0
#2 0x400e0c69:0x3ffb5a80 in cbuf::write(char const*, unsigned int) at C:\Users\user\.platformio\packages\framework-arduinoespressif32-src-c69fc9322995db5694e2741d307d9723\cores\esp32/cbuf.h:68
(inlined by) cbuf::write(char const*, unsigned int) at C:\Users\user\.platformio\packages\framework-arduinoespressif32-src-c69fc9322995db5694e2741d307d9723\cores\esp32/cbuf.cpp:171
#3 0x400869b6:0x3ffb5aa0 in tx_pwctrl_cal at /home/aiqin/git_tree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7_cal.c:2645
#4 0x4008763a:0x3ffb5ac0 in bootloader_flash_dummy_config at C:\Users\user\.platformio\packages\framework-espidf\components\bootloader_support\src/bootloader_flash_config.c:163
#5 0x4008764f:0x3ffb5ae0 in esp_reset_reason_set_hint at C:\Users\user\.platformio\packages\framework-espidf\components\esp32/reset_reason.c:106
#6 0x40085ad9:0x3ffb5b00 in bt_track_pll_cap at /home/aiqin/git_tree/chip7.1_phy/chip_7.1/board_code/app_test/pp/phy/phy_chip_v7_ana.c:1440
Rebooting...