Meditation Guru exception on SLIST_FOREACH

JoeThibodeau
Posts: 9
Joined: Mon Nov 11, 2019 11:34 am

Meditation Guru exception on SLIST_FOREACH

Postby JoeThibodeau » Mon Nov 11, 2019 12:01 pm

I am porting a C++ library to ESP32 and hit an exception on SLIST_FOREACH macro in 2 instances in the pthread_local_storage library.
I am using the latest IDF build. I am not calling this code directly. It is called within the module. My only clue is that list maybe null but how could it if pthread is a functional module.

Code from pthread_local_storage:

static value_entry_t *find_value(const values_list_t *list, pthread_key_t key)
{
value_entry_t *result = NULL;

SLIST_FOREACH(result, list, next) {
if(result->key == key) {
break;
}
}
return result;
}

PeterR
Posts: 223
Joined: Mon Jun 04, 2018 2:47 pm

Re: Meditation Guru exception on SLIST_FOREACH

Postby PeterR » Tue Nov 12, 2019 12:07 am

Hi,
Not sure that I follow your issue but I just hit an issue; pthread (freeRTOS wrapper) uses freeRTOS local storage index 0. The library I was porting also used local storage index 0. So I changed to index 1. Job done.
Seems to me that ESP are using a client store but live n let live, the fix is easy.

greengnu
Posts: 24
Joined: Wed May 08, 2019 8:45 pm

Re: Meditation Guru exception on SLIST_FOREACH

Postby greengnu » Tue Nov 12, 2019 11:49 am

Can you post the error and decoded call stack?

JoeThibodeau
Posts: 9
Joined: Mon Nov 11, 2019 11:34 am

Re: Meditation Guru exception on SLIST_FOREACH

Postby JoeThibodeau » Tue Nov 12, 2019 3:23 pm

Rebooting...
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:7092
load:0x40078000,len:14792
load:0x40080400,len:4468
entry 0x400806ec
I (73) boot: Chip Revision: 1
I (73) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (39) boot: ESP-IDF v4.1-dev-815-ga45e99853-dirty 2nd stage bootloader
I (39) boot: compile time 09:49:05
I (41) boot: Enabling RNG early entropy source...
I (46) boot: SPI Speed : 40MHz
I (50) boot: SPI Mode : DIO
I (54) boot: SPI Flash Size : 4MB
I (58) boot: Partition Table:
I (62) boot: ## Label Usage Type ST Offset Length
I (69) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (77) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (84) boot: 2 factory factory app 00 00 00010000 00100000
I (92) boot: End of partition table
I (96) boot_comm: chip revision: 1, min. application chip revision: 0
I (103) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x311f8 (201208) map
I (184) esp_image: segment 1: paddr=0x00041220 vaddr=0x3ffb0000 size=0x03390 ( 13200) load
I (190) esp_image: segment 2: paddr=0x000445b8 vaddr=0x40080000 size=0x00400 ( 1024) load
0x40080000: _WindowOverflow4 at C:/evtrac/esp-idf/components/freertos/xtensa_vectors.S:1778

I (191) esp_image: segment 3: paddr=0x000449c0 vaddr=0x40080400 size=0x0b658 ( 46680) load
I (219) esp_image: segment 4: paddr=0x00050020 vaddr=0x400d0020 size=0xb3b0c (736012) map
0x400d0020: _stext at ??:?

I (483) esp_image: segment 5: paddr=0x00103b34 vaddr=0x4008ba58 size=0x05244 ( 21060) load
0x4008ba58: spi_flash_chip_generic_write_encrypted at C:/evtrac/esp-idf/components/spi_flash/spi_flash_chip_generic.c:200

I (502) boot: Loaded app from partition at offset 0x10000
I (502) boot: Disabling RNG early entropy source...
I (503) cpu_start: Pro cpu up.
I (506) cpu_start: Application information:
I (511) cpu_start: Project name: ableLink
I (516) cpu_start: App version: v4.1-dev-815-ga45e99853-dirty
I (523) cpu_start: Compile time: Nov 11 2019 11:22:01
I (529) cpu_start: ELF file SHA256: 3159e314cbd70408...
I (535) cpu_start: ESP-IDF: v4.1-dev-815-ga45e99853-dirty
I (542) cpu_start: Starting app cpu, entry point is 0x40081190
0x40081190: call_start_cpu1 at C:/evtrac/esp-idf/components/esp32/cpu_start.c:276

I (529) cpu_start: App cpu up.
I (553) heap_init: Initializing. RAM available for dynamic allocation:
I (560) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (566) heap_init: At 3FFBA998 len 00025668 (149 KiB): DRAM
I (572) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (578) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (585) heap_init: At 40090C9C len 0000F364 (60 KiB): IRAM
I (591) cpu_start: Pro cpu start user code
I (613) spi_flash: detected chip: gd
I (613) spi_flash: flash io: dio
I (613) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (696) wifi: wifi driver task: 3ffc2494, prio:23, stack:3584, core=0
find_value : key 7, result 0, list 1073414132
I (696) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (696) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (726) wifi: wifi firmware version: af6bf13
I (726) wifi: config NVS flash: enabled
I (726) wifi: config nano formating: disabled
I (726) wifi: Init dynamic tx buffer num: 32
I (736) wifi: Init data frame dynamic rx buffer num: 32
I (736) wifi: Init management frame dynamic rx buffer num: 32
I (746) wifi: Init management short buffer num: 32
I (746) wifi: Init static rx buffer size: 1600
I (756) wifi: Init static rx buffer num: 10
I (756) wifi: Init dynamic rx buffer num: 32
find_value : key 7, result 1073460572, list 1073414132
find_value : key 7, result 1073460572, list 1073414132
find_value : key 7, result 1073460572, list 1073414132
I (916) phy: phy_version: 4102, 2fa7a43, Jul 15 2019, 13:06:06, 0, 0
I (916) wifi: mode : softAP (30:ae:a4:14:e1:15)
I (916) wifi: Total power save buffer number: 16
I (916) wifi: Init max length of beacon: 752/752
I (926) wifi: Init max length of beacon: 752/752
find_value : key 7, result 0, list 1073472844
Wifi softAP: wifi_init_softap SSID: Guild_1 password:
I (936) Wifi softAP: ESP_WIFI_MODE_AP
W (946) esp32_asio_pthread: pthread_condattr_setclock: not yet supported!
find_value : key 1, result 0, list 1073414132
C:/evtrac/esp-idf/Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x400fc208 PS : 0x00060130 A0 : 0x800fc2ec A1 : 0x3ffbc450
0x400fc208: find_value at C:/evtrac/esp-idf/components/pthread/pthread_local_storage.c:193

A2 : 0xe8189a7b A3 : 0x00000001 A4 : 0x0000001c A5 : 0x0000001c
A6 : 0x00000000 A7 : 0xff000000 A8 : 0x79a32d45 A9 : 0x3ffbc430
A10 : 0x3ffbc9d4 A11 : 0x00000001 A12 : 0x3ffd04e8 A13 : 0x3ffafff4
A14 : 0x00060720 A15 : 0x3f400010 SAR : 0x00000002 EXCCAUSE: 0x0000001c
EXCVADDR: 0xe8189a7b LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000

ELF file SHA256: 3159e314cbd70408d8f88c62e1f92cbec2e1dd10bd5404c83cdaeb259c7ed06a

Backtrace: 0x400fc205:0x3ffbc450 0x400fc2e9:0x3ffbc470 0x400fba49:0x3ffbc490 0x40104e02:0x3ffbc4f0 0x400d6e97:0x3ffbc510 0x
400d76e9:0x3ffbc730 0x400d7872:0x3ffbc7c0 0x400d1d06:0x3ffbc920 0x4008f689:0x3ffbc940
0x400fc205: find_value at C:/evtrac/esp-idf/components/pthread/pthread_local_storage.c:192

0x400fc2e9: pthread_getspecific at C:/evtrac/esp-idf/components/pthread/pthread_local_storage.c:209

0x400fba49: pthread_create at C:/evtrac/esp-idf/components/pthread/pthread.c:241

0x40104e02: __gthread_create at /builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-esp32-elf/build/build-cc-gcc-f
inal/xtensa-esp32-elf/libstdc++-v3/include/xtensa-esp32-elf/bits/gthr-default.h:675
(inlined by) std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >,
void (*)()) at /builds/idf/crosstool-NG/.build/HOST-i686-w64-mingw32/xtensa-esp32-elf/src/gcc/libstdc++-v3/src/c++11/threa
d.cc:135

0x400d6e97: ableton::link::Controller<std::function<void (unsigned int)>, std::function<void (ableton::link::Tempo)>, std::
function<void (bool)>, ableton::platforms::stl::Clock, ableton::platforms::asio::Context<ableton::platforms::esp32::ScanIpI
fAddrs, ableton::util::NullLog> >::Controller(ableton::link::Tempo, std::function<void (unsigned int)>, std::function<void
(ableton::link::Tempo)>, std::function<void (bool)>, ableton::platforms::stl::Clock, ableton::util::Injected<ableton::platf
orms::asio::Context<ableton::platforms::esp32::ScanIpIfAddrs, ableton::util::NullLog> >) at c:\esp32_win32_msys2_environmen
t_and_toolchain-20190611\msys32\opt\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\8.2.0/thread:126
(inlined by) ?? at C:/evtrac/esp-idf/components/ableton/include/ableton/platforms/asio/LockFreeCallbackDispatcher.hpp:47
(inlined by) ?? at C:/evtrac/esp-idf/components/ableton/include/ableton/link/Controller.hpp:554
(inlined by) ableton::link::Controller<std::function<void (unsigned int)>, std::function<void (ableton::link::Tempo)>, std
::function<void (bool)>, ableton::platforms::stl::Clock, ableton::platforms::asio::Context<ableton::platforms::esp32::ScanI
pIfAddrs, ableton::util::NullLog> >::Controller(ableton::link::Tempo, std::function<void (unsigned int)>, std::function<voi
d (ableton::link::Tempo)>, std::function<void (bool)>, ableton::platforms::stl::Clock, ableton::util::Injected<ableton::pla
tforms::asio::Context<ableton::platforms::esp32::ScanIpIfAddrs, ableton::util::NullLog> >) at C:/evtrac/esp-idf/components/
ableton/include/ableton/link/Controller.hpp:163

0x400d76e9: ableton::Link::Link(double) at C:/evtrac/esp-idf/components/ableton/include/ableton/Link.ipp:74 (discriminator
13)

0x400d7872: app_main at C:/evTrac/esp-idf/abletonDemo/main/main.cpp:160

0x400d1d06: main_task at C:/evtrac/esp-idf/components/esp32/cpu_start.c:569

0x4008f689: vPortTaskWrapper at C:/evtrac/esp-idf/components/freertos/port.c:143

JoeThibodeau
Posts: 9
Joined: Mon Nov 11, 2019 11:34 am

Re: Meditation Guru exception on SLIST_FOREACH

Postby JoeThibodeau » Tue Nov 12, 2019 4:27 pm

I think I have isolated the issue.

set_specific : key 7, entry 1073460588, list 1073472900
I (695) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
...
I (875) wifi: Init max length of beacon: 752/752
set_specific : key 7, entry 1073510272, list 1073461396
Wifi softAP: wifi_init_softap SSID: Guild_1 password:
I (895) Wifi softAP: ESP_WIFI_MODE_AP
W (895) esp32_asio_pthread: pthread_condattr_setclock: not yet supported!
get_specific : key 1, entry 0, list 1073472900
C:/evtrac/esp-idf/cGuru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC : 0x4018013c PS : 0x00060130 A0 : 0x800fc2d9 A1 : 0x3ffbc470


key 1 is retrieved but it isn't set. key 7 is stored to 2 different lists.
On to how to get key in a list.
I did change the local pointer list size to 2.

JoeThibodeau
Posts: 9
Joined: Mon Nov 11, 2019 11:34 am

Re: Meditation Guru exception on SLIST_FOREACH

Postby JoeThibodeau » Tue Nov 12, 2019 6:59 pm

Figured out the issue: This is stack space issue because main has a small stack. And because this application was in C++ using a pThread instead of FreeRTOS directly resulted in the component running. On to debugging the rest!

Who is online

Users browsing this forum: balaje, Bing [Bot] and 31 guests