INTERNAL_ERROR_BAD_THREAD_DISPATCH_ENVIRONMENT

Joel Sherrill joel at rtems.org
Mon Feb 19 17:06:44 UTC 2018


On Mon, Feb 19, 2018 at 10:20 AM, Matthew J Fletcher <amimjf at gmail.com>
wrote:

> Hi Joel,
>
> Its possible interrupts are disabled. I am using the
> termios RTEMS_IO_RCVWAKEUP callback to get chars from console input. I
> accumulate them for a timer tick or two, then in a timer callback
> do rtems_message_queue_send()
>
> The callstack above this from the rtems_message_queue_receive() in
> another task. The disable / enable interrupts wraps the  rtems_message_queue_send()
> and buffer management to protect against the timer being invoked again
> during that operation.
>

Wrapping the call to MQ in ISR disable is the culprit.



>
> Should i be using a semaphore instead ?
>

That should work as long as you use it no wait in the ISR. You don't want
to block in an ISR. That will trigger another fault. :)

Also watch out for the type of semaphore. If it has priority inheritance or
ceiling, it always has to be accessed from a thread.

--joel



>
>
>
>
>
> On 19 February 2018 at 15:38, Joel Sherrill <joel at rtems.org> wrote:
>
>>
>> Based on the code, it looks like you have interrupts disabled
>> when you are making the call to  rtems_region_get_segment().
>>
>> For sure, you shouldn't free memory from an ISR though.
>>
>> On Mon, Feb 19, 2018 at 9:33 AM, Matthew J Fletcher <amimjf at gmail.com>
>> wrote:
>>
>>> For those interested the callstack looks like this;
>>>
>>> bsp_fatal_extension() at bspclean.c:32 0x700d42ba
>>> _User_extensions_Iterate() at userextiterate.c:175 0x700ef42a
>>> _User_extensions_Fatal() at userextimpl.h:307 0x700eb9b2
>>> _Terminate() at interr.c:35 0x700eb9b2
>>> _Internal_error() at interr.c:52 0x700eb9e2
>>> _Thread_Do_dispatch() at threaddispatch.c:186 0x700edd0a
>>> _Thread_Dispatch_enable() at threaddispatch.h:227 0x700ef0f8
>>> _Thread_Change_life() at threadrestart.c:684 0x700ef0f8
>>> _Thread_Set_life_protection() at threadrestart.c:691 0x700ef10c
>>> _API_Mutex_Lock() at apimutexlock.c:29 0x700eae86
>>> _RTEMS_Lock_allocator() at allocatormutex.c:26 0x700eae6a
>>> _Region_Get_and_lock() at regionimpl.h:76 0x700e9cdc
>>> rtems_region_get_segment() at regiongetsegment.c:68 0x700e9cdc
>>> ...
>>> ... some of my code ...
>>> ...
>>> _Thread_Handler() at threadhandler.c:134 0x700edde2
>>> _Thread_Get() at threadget.c:38 0x700edda8
>>>
>>> Its not clear to me what the issue might be.
>>>
>>>
>>> On 19 February 2018 at 13:13, Matthew J Fletcher <amimjf at gmail.com>
>>> wrote:
>>>
>>>> All,
>>>>
>>>> Replying to my own post, with CPU_ENABLE_ROBUST_THREAD_DISPATCH set
>>>> FALSE i get a fatal exception, this on a Cortex-M7, rtems 5.0.0 from git.
>>>>
>>>> I think i will have to work around the new behavior somehow.
>>>>
>>>> --
>>>>
>>>> regards
>>>> ---
>>>> Matthew J Fletcher
>>>>
>>>>
>>>
>>>
>>> --
>>>
>>> regards
>>> ---
>>> Matthew J Fletcher
>>>
>>>
>>> _______________________________________________
>>> users mailing list
>>> users at rtems.org
>>> http://lists.rtems.org/mailman/listinfo/users
>>>
>>
>>
>
>
> --
>
> regards
> ---
> Matthew J Fletcher
>
>
> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/users/attachments/20180219/0cde8878/attachment-0002.html>


More information about the users mailing list