Illegally dereferenced pointer may be incorrect

7 visualizaciones (últimos 30 días)
Tran Thang
Tran Thang el 30 de Dic. de 2020
Comentada: Tran Thang el 22 de Feb. de 2021
Hi Technical Support Team
I got a concern about orange warning at line 1065. Because array u1t_ArSrcSignalData[] is not NULL and index of it as 0.
Why Code Power throw out the orange warning at there?
Please take a look pic:
Please take a look pic below to see tooltip to get more info:
  1 comentario
Tran Thang
Tran Thang el 30 de Dic. de 2020
Editada: Tran Thang el 30 de Dic. de 2020
Hi Technical Support Team
I add lines of code to check u1t_ArSrcSignalData != NULL before used it.
But CP still throw out the orange warning.
Please help me how to disappear this warning?
BR

Iniciar sesión para comentar.

Respuesta aceptada

Anirban
Anirban el 7 de En. de 2021
The orange warning does not mean that the pointer is null. In fact, you can see in the message that the pointer is not null. (This is also why your later if statement appeared grey since the if condition is always true.)
The orange warning appears because the pointer is suspected to be pointing outside the allowed buffer. The part of the message that says "may be outside bounds" indicates this.
The other things that I can deduce from the message are:
  • The pointer might be some kind of a global pointer, since it points to what appears like local variables in different functions.
  • The second line of the message indicating "If appropriate, applying DRS to ..." indicates that the tool is having to make an assumption on that particular line for the variable pu1t_SignalData (because its value is not known), which leads to a possibly imprecise result. You can externally constrain this variable if you want and that might lead to the orange going away. See Specify External Constraints.
However, since the tool deduces that there are 67 (!) different candidates for what the pointer might point to, I am inclined to think there might be an overapproximation happening somewhere in the middle too. This will require deeper investigation.
  3 comentarios
Anirban
Anirban el 3 de Feb. de 2021
I can start from the second question. Using the option auto can be sometimes better in terms of precision. If you use this option, for leaf functions, the analysis keeps track of call contexts separately and does not merge the information. So, the results involve less approximations and can be more precise. You can find more in the documentation for Sensitivity context. However, the option can increase analysis time significantly (and in specific cases can lead to some confusion in the messages).
So, the best use of the option is the following: suppose you have an orange check in a function and the function is called in several places. You want to know which of those calls causes a problem. Then you can select custom for the option and add that function name. The analysis will show which of the calls are green and which ones are orange or red. In other words, the option is best used in the additional diagnosis of a check and probably should otherwise have none by default.
In this specific instance, when the message asks you to apply DRS on pu1t_SignalData, it is actually asking you to use the option Constraint setup (-data-range-specifications). Right now, it seems like Code Prover might be assuming a large range for this variable solely based on its data type. If the variable represents a physical quantity, you can externally impose a narrower range on the variable to represent what values it can really have and possibly get rid of the orange check.
About your first question, I am not sure I understand the question fully. You are probably suggesting that you changed the source code, yet the message 'maybe outside bounds' remains. It seems to me that your change actually led to the check becoming green. About why the message still says 'maybe outside bounds', I cannot tell from this screenshot itself. It might be related to your use of the option 'Sensitivity context' somehow. If you contact support (https://www.mathworks.com/support/contact_us.html), they can help you diagnose further.
Tran Thang
Tran Thang el 22 de Feb. de 2021
Thank you for your answer.
My side only take care orange and analyze it if it is defect or not.
"If appropriate, applying DRS to ..." is happened randomly, So we can't count and control this warning.
It make us confuse whether changed source affect to it or not.
BR/ Thang Tran

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by