Error on strtok_r

william.basser
Posts: 2
Joined: Fri Sep 19, 2025 2:08 pm

Error on strtok_r

Postby william.basser » Fri Sep 19, 2025 2:13 pm

I have a software module that parses incoming commands and tokenizes the command buffer into arguments. I get the following error when it attempts to parse the buffer
I (184388) CTLASCCMD:: Event Received 0
Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.

Core 0 register dump:
PC : 0x4000c6d8 PS : 0x00060830 A0 : 0x8000c71a A1 : 0x3ffb79d0
--- 0x4000c6d8: __strtok_r in ROM
A2 : 0x3ffb7cc4 A3 : 0x3ffb7a10 A4 : 0x00000000 A5 : 0x00000001
A6 : 0x000047eb A7 : 0x3ffb295c A8 : 0x3ffb7cc5 A9 : 0x00000000
A10 : 0x3ffb7a15 A11 : 0x00000000 A12 : 0x00060a20 A13 : 0x00000000
A14 : 0x00000001 A15 : 0x3ffb2a84 SAR : 0x00000004 EXCCAUSE: 0x0000001d
EXCVADDR: 0x00000000 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff
--- 0x4000c2e0: memcpy in ROM
--- 0x4000c2f6: memcpy in ROM


Backtrace: 0x4000c6d5:0x3ffb79d0 0x4000c717:0x3ffb79f0 0x400d8736:0x3ffb7a10 0x400d88ee:0x3ffb7a40 0x400d846d:0x3ffb7a70 0x40086f75:0x3ffb7aa0
--- 0x4000c6d5: __strtok_r in ROM
--- 0x4000c717: strtok_r in ROM
--- 0x400d8736: ParseBuffer at D:/esp32dev/ProjectTest1/components/CommandLineInterface/CommandLineInterface.c:816
--- 0x400d88ee: CommandLineInterface_ProcessChar at D:/esp32dev/ProjectTest1/components/CommandLineInterface/CommandLineInterface.c:260
--- 0x400d846d: ProcessChar at D:/esp32dev/ProjectTest1/main/CtlAscCmdHandler.c:244
--- 0x40086f75: vPortTaskWrapper at C:/Espressif/frameworks/esp-idf-v5.5.1/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c:139

Any ideas?
Attachments
CommandLineInterface.zip
Source file
(8.55 KiB) Downloaded 41 times

MicroController
Posts: 2669
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: Error on strtok_r

Postby MicroController » Fri Sep 19, 2025 9:09 pm

Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.

Core 0 register dump:
...
EXCVADDR: 0x00000000
Store to a null pointer was attempted.
...
--- 0x400d8736: ParseBuffer at D:/esp32dev/ProjectTest1/components/CommandLineInterface/CommandLineInterface.c:816
...

Any ideas?
Can't pass NULL to strtok_r().

Instead of

Code: Select all

PPC8            pccTemp = NULL;
...
    // get the command
    pcArg = strtok_r( ptCmdLinCtl->pcBuffer, szDelims, pccTemp );
you want

Code: Select all

PC8 pcTemp = NULL;
...
    // get the command
    pcArg = strtok_r( ptCmdLinCtl->pcBuffer, szDelims, &pcTemp );

Who is online

Users browsing this forum: Google [Bot], Qwantbot, RandomInternetGuy, Semrush [Bot] and 3 guests