code prover result analysis request // Global Variable – Shared - Potentially unprotected variable

6 次查看(过去 30 天)
polyspace result analysis request
check result: Potentially unprotected variable
color: orange
check result detail
Global Variable – Shared - Potentially unprotected variable
Variable 'Appl_Rand.ApplRand_RandNo' is shared among several tasks. Some operations on variable 'Appl_Rand.ApplRand_RandNo' have no common protection.
Read by task: Os_Task_OsTask100ms Os_Task_OsTask10ms Os_Task_OsTask20ms Os_Task_OsTask5ms
Written by task: Os_Task_OsTask100ms Os_Task_OsTask10ms Os_Task_OsTask20ms Os_Task_OsTask5ms
check result count: 160 ea
question
1) what polyspace setting related this output?
2) any usecase for solving this kind of issue(not using semaphore or similiar method)
3) I am using Vector AUTOSAR, do you have experience with other customer?

回答(1 个)

Akshat Dalal
Akshat Dalal 2024-10-26,9:51
The issue of "Potentially unprotected variable" arises in Polyspace Code Prover when analyzing multitasking programs. By default, Polyspace does not analyze concurrent tasks unless you enable it. For more details, refer to the Polyspace documentation on https://www.mathworks.com/help/codeprover/ug/analyze-multitasking-programs-in-polyspace.html
If you prefer not to use semaphores or similar synchronization mechanisms to address the unprotected access warnings, consider the following workaround:
  • Specify Temporally Exclusive Tasks: You can artificially specify that all tasks accessing the global shared variable are temporally exclusive. This means treating them as if they do not run concurrently, even if they might during actual execution. This approach will:
  • Change the variable's flag from orange to green, indicating no unprotected access.
  • Eliminate the need to review these specific checks.
  • Ensure that other runtime checks remain unaffected.
For further information on how to specify temporally exclusive tasks, use cases and corner cases is available at the documentation page linked here:
Alternatively, if the requirement is to filter out the results for this check from the report, this could be done by using the documentation page linked here:

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by