Keil Logo

ARM: RTXv5 reports error "osRtxErrorStackUnderflow"

Information in this knowledgebase article applies to:

  • MDK-ARM v5
  • Pack: ARM CMSIS v5.00 or later
  • RTXv5


When using RTXv5, an implementation of CMSIS RTOSv2 API, my application throws the following error:


before entering into an endless loop in the function osRtxErrorNotify().

What could be causing this issue?


Likely, the stack of a thread was not allocating enough memory, before the thread started executing.


To find out which thread requires more resources, select the Source component variant for RTXv5, from the Manage Run-Time Environment dialog.

Manage RTE RTXv5 source variant

  • Note: In all versions of ARM's CMSIS pack, some users may receive the following warning or error message in the source file "rtx_kernel.c". Modify your project's settings accordingly:

    error:  #29: expected an expression   { .os_id = osRtxKernelId,

    armcc users can either enable "C99 Mode" or add the flag "--c99" to a source file's Options dialog => C/C++ tab => Misc. Controls to resolve the error.

     warning: designated initializers are a C99 feature [-Wc99-extensions]

    To avoid these warnings, armclang users can either select "c99" from the "Language C:" drop-down list in the C/C++ (AC6) tab, or use the flag "--std=c99".

After bringing in the RTXv5 source, in editor mode, go to the definition of the function osRtxThreadStackCheck(). Set a breakpoint at the call to osRtxErrorNotify(). Users can do this at optimization level 0. In debug mode, a custom Component Viewer dialog called RTX RTOS (View => Watch Windows => RTX RTOS) displays the status of all v2 threads. After running to the breakpoint, find the active thread. Exit debug mode, and increase the thread's stack size.




The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Tuesday, April 4, 2017

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.