Menu

#203 Crash in prvProcessSimulatedInterrupts() in Windows port

v1.0 (example)
open
nobody
None
5
2022-08-24
2022-05-11
No

I have found a crash in Windows port of FreeRTOS in port.c

I have found that pxCurrentTCB is NULL

/* Obtain the state of the task now selected to enter the
                Running state. */
                pxThreadState = ( ThreadState_t * ) ( *( size_t *) pxCurrentTCB );

Callstack:

>   plugin_AeroSIMRC.dll!prvProcessSimulatedInterrupts()  Line 496 + 0x5 bytes  C
    plugin_AeroSIMRC.dll!xPortStartScheduler()  Line 362    C
    plugin_AeroSIMRC.dll!vTaskStartScheduler()  Line 1084   C

The proposed fix:

if(pxCurrentTCB != NULL)
                {
                  /* Obtain the state of the task now selected to enter the
                  Running state. */
                  pxThreadState = ( ThreadState_t * ) ( *( size_t *) pxCurrentTCB );

                  /* pxThreadState->pvThread can be NULL if the task deleted
                  itself - but a deleted task should never be resumed here. */
                  configASSERT( pxThreadState->pvThread != NULL );
                  ResumeThread( pxThreadState->pvThread );
                }

Discussion

  • Jaroslav Fojtik

    Jaroslav Fojtik - 2022-05-11

    Please note that this crash was not immediate. It occurred after one hour of FreeRTOS app run.

    I have investigated this problem and it might be a side effect of calling xSemaphoreGiveFromISR() from non FreeRTOS thread. I needed to simulate IRQ from something that cannot belong to FreeRTOS thread chunk.

     

    Last edit: Jaroslav Fojtik 2022-05-11

Log in to post a comment.

MongoDB Logo MongoDB