I observed that the reculock implementation in locks.c file is not safe for use by multiple cores. reculock array is a shared resource that is not protected from simultaneous usage by separate cores. If two cores use two distinct recursive locks in parallel with high frequency, corruption occurs and system crashes.
Expected behavior
The system works in a stable manner.
Actual behavior
System crashes.
Test code
reculock_t reculock[LOCK_MAX_NUM];
...
static reculock_t *get_free_reculock(void)
{
reculock_t *ret = NULL;
for(uint32_t i = 0; i < LOCK_MAX_NUM; i++)
{
// we should make sure that this logic does not run in parallel on both cores
if(reculock[i].lock == NULL){
ret = &reculock[i];
break;
}
}
return ret;
}
I observed that the reculock implementation in locks.c file is not safe for use by multiple cores. reculock array is a shared resource that is not protected from simultaneous usage by separate cores. If two cores use two distinct recursive locks in parallel with high frequency, corruption occurs and system crashes.
Expected behavior
The system works in a stable manner.
Actual behavior
System crashes.
Test code
Document version
present master
Hardware
KD233
System
Linux