InstrFetchProhibited when using xTaskCreatePinnedToCore

Zhassan
Posts: 4
Joined: Mon Sep 06, 2021 6:29 am

InstrFetchProhibited when using xTaskCreatePinnedToCore

Postby Zhassan » Mon Sep 06, 2021 6:45 am

Have been trying to solve this issue for a while, Still no luck!

My code is working fine when I am running everything from the main loop but it crashes (after an hour) when I run a part of it from a second Task running on core 0. I am using Arduino IDE for sketching.

The error is:
Guru Meditation Error: Core 0 panic'ed (InstrFetchProhibited). Exception was unhandled.
16:02:28.238 -> Core 0 register dump:
16:02:28.238 -> PC : 0xb440083e PS : 0x00060e33 A0 : 0x80001e29 A1 : 0x3ffbe3b0
16:02:28.238 -> A2 : 0x3ffae0a8 A3 : 0x00000001 A4 : 0x40084230 A5 : 0x3ffb8c20
16:02:28.238 -> A6 : 0x00000000 A7 : 0x3ffbbf60 A8 : 0x8000be38 A9 : 0x3ffbe780
16:02:28.238 -> A10 : 0x3ffae0a8 A11 : 0x3ffc1b8c A12 : 0x00000001 A13 : 0x00000001
16:02:28.238 -> A14 : 0x00060a20 A15 : 0x00000000 SAR : 0x00000014 EXCCAUSE: 0x00000014
16:02:28.238 -> EXCVADDR: 0xb440083c LBEG : 0x00000000 LEND : 0x00000000 LCOUNT : 0x00000000
16:02:28.238 -> Core 0 was running in ISR context:
16:02:28.238 -> EPC1 : 0xb440083e EPC2 : 0x00000000 EPC3 : 0x00000000 EPC4 : 0x00000000
16:02:28.238 ->
16:02:28.238 -> ELF file SHA256: 0000000000000000
16:02:28.238 ->
16:02:28.238 -> Backtrace: 0x7440083e:0x3ffbe3b0 0x40001e26:0x3ffbe3d0 0x40001e3b:0x3ffbe3f0 0x400e2979:0x3ffbe410 0x400de53d:0x3ffbe6d0 0x400de450:0x3ffbe720 0x40087ec5:0x3ffbe750 0x40088682:0x3ffbe780 0x40086f5f:0x3ffbe7a0 0x4008964d:0x3ffbe7c0 0x4008429e:0x3ffbe7d0 0x400fcf33:0x3ffbc270 0x400f36e3:0x3ffbc290 0x4008864d:0x3ffbc2b0 0x40086e72:0x443ffbc2

Using the Exception Decoder, The following is received:

Decoding stack results
0x400e2979: _vfiprintf_r at ../../../.././newlib/libc/stdio/vfprintf.c line 859
0x400de53d: fiprintf at ../../../.././newlib/libc/stdio/fiprintf.c line 50
0x400de450: __assert_func at ../../../.././newlib/libc/stdlib/assert.c line 59
0x40087ec5: vTaskEnterCritical at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/portmux_impl.inc.h line 105
0x40088682: xTaskIncrementTick at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 2490
0x40086f5f: xPortSysTickHandler at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 289
0x400fcf33: esp_pm_impl_waiti at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/pm_esp32.c line 492
0x400f36e3: esp_vApplicationIdleHook at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/esp32/freertos_hooks.c line 63
0x4008864d: prvIdleTask at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/tasks.c line 3382
0x40086e72: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
I have defined the task as following.. Tried increasing the stack size (up to 10,000)but the same issue persists..

Code: Select all

xTaskCreatePinnedToCore(
                  Task1code,   /* Task function. */
                  "Task1",     /* name of task. */
                  2000,       /* Stack size of task */
                  NULL,        /* parameter of the task */
                  1,           /* priority of the task */
                  &Task1,      /* Task handle to keep track of created task */
                  0);          /* pin task to core 0 */
I think the issue is related to using FreeRTOS, that is creating the 2nd task but I am not able to solve it on my own.. Any help would be appreciated..
Please note, I am still a beginner in the esp32 programming.

Thanks,
Zohair

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: InstrFetchProhibited when using xTaskCreatePinnedToCore

Postby chegewara » Mon Sep 06, 2021 9:37 am

Try to increase task stack size.

Zhassan
Posts: 4
Joined: Mon Sep 06, 2021 6:29 am

Re: InstrFetchProhibited when using xTaskCreatePinnedToCore

Postby Zhassan » Mon Sep 06, 2021 11:09 am

Hi,
Thanks for your response.. I have tried updating the task stack size but I don't think the issue is related to it. Increasing the task stack size didn't solve the problem either..

ESP_Sprite
Posts: 9730
Joined: Thu Nov 26, 2015 4:08 am

Re: InstrFetchProhibited when using xTaskCreatePinnedToCore

Postby ESP_Sprite » Tue Sep 07, 2021 1:09 am

Could be that you have a buffer overflow somewhere else in your code that happens to trigger the error when you run the code on a second task.

Zhassan
Posts: 4
Joined: Mon Sep 06, 2021 6:29 am

Re: InstrFetchProhibited when using xTaskCreatePinnedToCore

Postby Zhassan » Tue Sep 07, 2021 2:27 am

Thanks for the feedback. I cant find an overflow anywhere in the code... The last test was conducted with main loop having 32kb stack size and each additional task having 5kb.
I was monitoring the free stack space using uxTaskGetStackHighWaterMark() in each task and none of them came close to overflowing.

When I received the error, I had around 25000 free stack in the main loop and around 3500 bytes in each additional task..
Is there anything else that can cause the issue.. I have tried changing the power supply and the esp32 controller and don't think that's the issue..

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: InstrFetchProhibited when using xTaskCreatePinnedToCore

Postby chegewara » Tue Sep 07, 2021 7:14 am

0x400e2979: _vfiprintf_r at ../../../.././newlib/libc/stdio/vfprintf.c line 859
Is suggesting you are having some printf, sprintf or similar functions (maybe ESP_IDFx) in your task, and the snippet shows that task stack size is only 2000, which is not enough in that case. You need at least 3-3.5kB stack size.

Zhassan
Posts: 4
Joined: Mon Sep 06, 2021 6:29 am

Re: InstrFetchProhibited when using xTaskCreatePinnedToCore

Postby Zhassan » Tue Sep 07, 2021 7:32 am

chegewara wrote:
Tue Sep 07, 2021 7:14 am
0x400e2979: _vfiprintf_r at ../../../.././newlib/libc/stdio/vfprintf.c line 859
Is suggesting you are having some printf, sprintf or similar functions (maybe ESP_IDFx) in your task, and the snippet shows that task stack size is only 2000, which is not enough in that case. You need at least 3-3.5kB stack size.
Hi, I am not using printf or any similar function in the code... I have increased the stack size to 10kb, its still crashing.

chegewara
Posts: 2364
Joined: Wed Jun 14, 2017 9:00 pm

Re: InstrFetchProhibited when using xTaskCreatePinnedToCore

Postby chegewara » Tue Sep 07, 2021 5:25 pm

Maybe you could post code from that task?

Who is online

Users browsing this forum: No registered users and 115 guests