I am trying to run FreeRTOS + POSIX demo code on Spike - RISCV simulator
FreeRTOS Source from
I see that the pxDispatcher and pxWorkers[] are created and messages do get passed between the threads via Messages Q. The problem is with Mutex - pxThread->xJoinMutex , structure getting corrupted.
Issue :
Memory corruption leads to Assert condition in configASSERT at
configASSERT( !( ( pvItemToQueue == NULL ) && ( pxQueue->uxItemSize != ( UBaseType_t ) 0U ) ) ); via xQueueGenericSend - xSemaphoreGive( ( SemaphoreHandle_t ) &pxThread->xJoinMutex );
back trace from gdb
#1 0x0000000080004990 in Sleep (count=count@entry=100) at main.c:102
#2 0x0000000080004a0a in vAssertCalled (pcFile=pcFile@entry=0x80050210 “…/Source/queue.c”, ulLine=ulLine@entry=788) at main.c:171
#3 0x0000000080000aec in xQueueGenericSend (xQueue=xQueue@entry=0x80050f68 <ucHeap+1168>, pvItemToQueue=pvItemToQueue@entry=0x0, xTicksToWait=, xTicksToWait@entry=0, xCopyPosition=xCopyPosition@entry=0) at …/Source/queue.c:788
#4 0x00000000800057aa in pthread_join (pthread=0x80050eb8 <ucHeap+992>, retval=retval@entry=0x0) at …/Source/lib/FreeRTOS-Plus-POSIX/source/FreeRTOS_POSIX_pthread.c:462
#5 0x000000008000492e in vStartPOSIXDemo (pvParameters=) at posix_demo.c:374
#6 0x00000000800004e0 in prvSetNextTimerInterrupt () at …/Source/portable/GCC/RISC-V/port.c:139
Backtrace stopped: frame did not save the PC
pxQueue->uxItemSize and pxQueue->uxMessagesWaiting variables of pxThread->xJoinMutex have 0x80000fb4 (vPortYield+) and 0x80000466 (xQueueReceive +) addresses, when expected value for both should be 0.
Looks like xSemaphoreCreateMutexStatic( &pxThread->xJoinMutex ); --> Queue structure’s on heap is getting corrupted.
I am running the Demo code with MQUEUE_NUMBER_OF_WORKERS set 1.
I have tried to use the default FreeRTOS_POSIX_portable.h , _default.h FreeRTOSConfig.h, not sure if i am missing any specific define ?
I have tried adding watch *(int *) 0x80050fd8, but no luck. Dont hit the break point.
Pls let me know how to resolve this issue, Thanks
S