Error: OS_ERR_INV_TASK

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • Error: OS_ERR_INV_TASK

    Hi everyone,

    my application suddenly runs into OS_Error() with Error Code: 128 (OS_ERR_INV_TASK) at startup.
    The call stack does not give much information. The first entry I see is [OS_EXCEPTION + 0x21].

    This only happens if I compile with debug settings, not with release settings (optimization turned on). Since the problem only occured recently and the memory is running low, I suspect the issue in that area.
    When I run into this breakpoint the stack sizes seem to be ok, no sign of an overflow.

    It could be a problem with dynamic memory allocation. I'll look into that next but first I'd like to know more about this error and possible scenarios that could trigger this error.

    Any help would be greatly appretiated.

    Thanks,
    Florian
  • Hi Florian,

    This only happens if I compile with debug settings, not with release settings (optimization turned on).

    Do you use the embOS release library in your release configuration?
    The debug code is not included in the embOS release library.
    The application error still exists but there is no debug code which catches this error.

    I'll look into that next but first I'd like to know more about this error and possible scenarios that could trigger this error.

    This error means that the task control block was overwritten and is not longer valid.
    You could have a look in the task control block in a watch window.

    Without more information it's hard to say what could go wrong.
    Maybe you have a buffer overflow and your application overwrites the task control block.

    Best regards,
    Til
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Til,

    thanks for your reply.

    I dont think we use the embos release lib in our config.
    I'll definately have to debug some more. If you have any other suggestions where I could look to find some answers in my application or the os, please let me know.

    Thanks
    Florian
  • Hi Florian,

    The task control block includes the member "Id".
    The acutal debug check tests if the value in this member is still valid.
    You could set a watchpoint on this variable to find out when/where it is changed.

    Regards,
    Til
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • Hi Til,

    I can't always reproduce this. When I build my project with 'Release' Settings, it always works. After I have done this it also works for a while when I build with 'Debug' Settings.
    Now I ran into the problem again and could identify what Task Ids changed. It was 'USBH_Task' and 'USBH_ISR' from the Segger emUSB lib. Have you ever seen this before?
    There wasn't even a USB Stick attached to the system.

    -Florian
  • Hi Florian,

    When I build my project with 'Release' Settings, it always works.

    Are you sure that it works? OS_Error() is not called with release library because there is no debug code in release library.

    After I have done this it also works for a while when I build with 'Debug' Settings.

    Sounds strange to me.

    Now I ran into the problem again and could identify what Task Ids changed. It was 'USBH_Task' and 'USBH_ISR' from the Segger emUSB lib. Have you ever seen this before?

    I am not aware of any problems with emUSB Host.
    Could you please set a watchpoint on the Id member and try to identify where the value is changed?

    If you are working with licensed software you can In case of doubt also contact our support directly.
    That would make it easier to help you.

    Best regards,
    Til
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.
  • The problem is now resolved.

    It turned out that we send OS_Events to a certain task that was not yet initialized in some circumstances. That means the Id is 0 and we'll get an OS_Error.

    Thanks for the support.