This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/MSP432p401r: Task switch raises Task_E_stackOverflow and Task_E_spOutOfBound

Part Number: MSP432p401r

Tool/software: TI-RTOS

When debugging a project it was noticed that a Task_E_stack_Overflow and Task_E_spOutOfBounds error was raised every time a task switch occurred. Viewing the stacks and stack peaks showed that an overflow had not occurred and that the 0xbe cookie was present. The project appeared to operate correctly otherwise.

To isolate the problem a simple task was created that went to sleep once a counter reached a certain value. Breakpoints were placed in Task_checkStacks() and it was observed that on the switch to the idle task an overflow and out of bounds error was raised. The screen shot below shows where the error was raised as well as the code used, stack trace, ROV view of Tasks and Hwi module.

Device: MSP432P401R

SDK: 1.60.00.12

CCS: 7.4.0.00015

The stack peaks indicate that overflow should not be occurring. TaskSupport_checkStack() returns false when *stack is compared to the cookie which indicates a stack overflow has occurred or it is corrupted. From the memory browser it appears that the stack is being written continuously to. The next screen shot shows what is occurring.

It is a similar situation for every task switch. At this point I imported the 'events' example from Resource Explorer, built the project and placed the breakpoints in Task_checkStacks(). Again, I saw the same errors being raised even though there was no overflow and 0xbe was present.

Why am I getting this error? Has the stack been corrupted somehow or is there corruption occurring elsewhere? How do I stop this error from occurring?

The configuration file for the code used in the screen shots is attached. Thank you in advance.

1854.hello.cfg

  • Hello Will,

    Are you using an example from the SDK or your own application? If you are using your own application, can you provide that so that I can try to re-create the error?

    Thanks,
    Sai
  • The first post uses my own application. I will attach the files below. The event example was from the SDK (I imported that through Resource Explorer within CCSv7). The screen shot below shows what happened when I ran the example with a breakpoint in Task.c at line 408 and continued to step through execution. 

    8883.main.cpp

    2063.hello.cfg

  • Hello Will,

    Will Schuetz said:
    When debugging a project it was noticed that a Task_E_stack_Overflow and Task_E_spOutOfBounds error was raised every time a task switch occurred.

    How did you notice this error? Was this error printed on the console or did you notice it by placing a breakpoint?

    When I ran the "event" example (./examples/rtos/MSP_EXP432P401R/sysbios/event) without any breakpoints everything ran as expected.

    Even when I placed a breakpoint at the end of "readertask" in "event.c" file (which is the last line before the BIOS exists), I noticed no error in ROV or on the console.

    If you have noticed this error by placing the breakpoint, then that could be because the IDE might not have been able to pause at the exact location due to linker optimization. Do you notice these errors without placing any breakpoint?

    Thanks,

    Sai

  • This error was noticed by placing breakpoints and stepping through execution (F5). The first and third screen shots show where the breakpoints were placed in Task.c for both programs. The error was not printed to the console and the programs seem to run correctly. The fact that the errors were being hit (with breakpoints) and that stepping through TaskSupport_checkStack() showed that the function was returning false (as shown in the screen shots above) caused me concern. Are you saying that it only looks like errors are being raised?

  • Hello Will,

    Will Schuetz said:
    Are you saying that it only looks like errors are being raised?

    If the errors were actually raised, you would have seen it in the console (especially the stack overflow error that typically gets reported on the console). So I think the error you are noticing with breakpoints are not really errors.

    The reason for the above behavior could be because, the assembly code (generated by the toolchain) is not always arranged exactly as the C code. Functionally the assembly code will be the same as the C code, but the sequence of assembly instructions does not necessarily have to be the same as the C code. Due to this the IDE might show that it has paused at a different line when single stepping. 

    Single stepping in the dis-assembly window would be a better option.

     Thanks,

    Sai

**Attention** This is a public forum