secStoreServer.c SetCurrSystem() 348 | Could not get the current system's hash. LE_NOT_FOUND

Dear Legato :
In the legato framework logs I see an EMR error on the securestorage that could be the root cause of the defect, can you please help check ?

log 1:

[0 syslog failed]<8>Aug 31 14:16:50 Legato: EMR | secStore[2019]/secStoreDaemon T=main | secStoreServer.c SetCurrSystem() 348 | Could not get the current system’s hash. LE_NOT_FOUND.

575050 2022/08/31 14:16:50.181977 53.4373 185 NAD SYS SYSL 0 log info verbose 1 [0 syslog failed]<14>Aug 31 12:16:50 Legato: INFO | supervisor[1737]/supervisor T=main | proc.c proc_SigChildHandler() 2077 | Process ‘secStore’ (PID: 2019) has exited with exit code 1.

log2:

20749 2022/05/31 16:23:57.844821 54.3338 167 NAD SYS SYSL 0 log info verbose 1 [0 syslog failed]<8>May 30 11:12:19 Legato: EMR | secStore[2042]/secStoreDaemon T=main | secStoreServer.c SetCurrSystem() 348 | Could not get the current system’s hash. LE_NOT_FOUND.

20758 2022/05/31 16:23:57.844821 54.3472 171 NAD SYS SYSL 0 log info verbose 1 [0 syslog failed]<14>May 30 11:12:19 Legato: INFO | supervisor[1773]/supervisor T=main | proc.c proc_SigChildHandler() 2077 | Process ‘secStore’ (PID: 2042) has exited with exit code 1.


I analyzed the Legato source code and seems that the issue is due to the initialization phase of secstore when an app is removed/installed.
In detail the false return of function system_Exists(int systemIndex) in the file system.c trigger the EMR error and the exit 1 of secstore.

le_result_t system_GetSystemHash(

if (system_Exists(systemIndex) == false)
{
return LE_NOT_FOUND;
}

Have you noticed any of these problems before? Please help analyze the logs/source code , It would be better if you had a fix for this issue, and we look forward to your response, thank you very much!

what is the exact problem you encountered?
How to reproduce the issue?

the defect is secStore crash on boot and system will reboot.

16:23:57.844821 54.3338 167 NAD SYS SYSL 0 log info verbose 1 [0 syslog failed]<8>May 30 11:12:19 Legato: EMR | secStore[2042]/secStoreDaemon T=main | secStoreServer.c SetCurrSystem() 348 | Could not get the current system’s hash. LE_NOT_FOUND.
16:23:57.844821 54.3472 171 NAD SYS SYSL 0 log info verbose 1 [0 syslog failed]<14>May 30 11:12:19 Legato: INFO | supervisor[1773]/supervisor T=main | proc.c proc_SigChildHandler() 2077 | Process ‘secStore’ (PID: 2042) has exited with exit code 1.
16:23:57 54.4789 ERR [0 syslog failed]<10>May 30 11:12:20 Legato: CRT | supervisor[1773]/supervisor T=main | app.c app_SigChildHandler() 4061 | Process ‘secStore’ in app ‘secStore’ faulted: Restarting app.
16:23:57 54.4977 ERR [FappManager] [ HandleMiddlewareAppFault ] Middleware app secStore exited following to exit 1
16:23:57 54.4712 ERR [FappManager] [ secStore ] Faulted!
16:23:57 54.4789 ERR [0 syslog failed]<10>May 30 11:12:20 Legato: CRT | supervisor[1773]/supervisor T=main | app.c app_SigChildHandler() 4061 | Process ‘secStore’ in app ‘secStore’ faulted: Restarting app.
16:23:57 54.4977 ERR [FappManager] [ HandleMiddlewareAppFault ] Middleware app secStore exited following to exit 1
16:23:57 54.4977 ERR [FappManager] System will reboot

legato/framework/daemons/linux/updateDaemon/system.c updateDaemon.c
legato/platformAdaptor/qmi/src/ag35x/components/le_pa_secStore/pa_secStore.c
The two generated system_index are inconsistent,and the code flow diagram is as follows:

I guess how the issue happened: legato (as a system) will increase the value of legato/systems/current/index by 1 and re-write to the index when there is app installing or removing. The code gets this index value twice: BEFORE and AFTER adding 1 to the value (x and x+1). Getting a different index in this action is the cause why this issue happened. we have to put it under high stress testing that can reproduce it.

did you try to “update --mark-good” after installing the application?

no, I didn’t do that

you can try that and see if it helps

hello jyijyi
“update --mark-good”
what is this statement for?

you can see here: