Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing SPARK_Mode in generic Write procedures in tests #287

Closed
jklmnn opened this issue Jun 15, 2020 · 5 comments
Closed

Missing SPARK_Mode in generic Write procedures in tests #287

jklmnn opened this issue Jun 15, 2020 · 5 comments
Assignees
Labels
bug generator Related to generator package (SPARK code generation)

Comments

@jklmnn
Copy link
Member

jklmnn commented Jun 15, 2020

Multiple tests implement a generic Write_Data procedure to be used in generic set procedures for opaque fields:

procedure Write_Data (Buffer : out RFLX_Builtin_Types.Bytes) is                                                      
begin                                                                                                                
   Buffer := Data (Data'First .. Data'First + Buffer'Length - 1);                                                    
end Write_Data;

The assignment to Buffer cannot be proven since its length depends on the call and it has no precondition.
The quick fix would be to enable SPARK_Mode and check for the length (and e.g. use a default value to initialize if the check fails).
To actually prove the length the length of Buffer has to be a precondition to Set_* and Set_Bounded_* procedures.

@jklmnn jklmnn created this issue from a note in RecordFlux 0.4.1 (To do) Jun 15, 2020
@jklmnn jklmnn self-assigned this Jun 15, 2020
@jklmnn jklmnn moved this from To do to In progress in RecordFlux 0.4.1 Jun 15, 2020
@treiher
Copy link
Collaborator

treiher commented Jun 15, 2020

We should not just apply the quick fix. The generated SPARK code should be adapted so that the Set_* and Set_Bounded_* procedures can be used in a secure and sensible way.

@treiher treiher added bug generator Related to generator package (SPARK code generation) labels Jun 15, 2020
@jklmnn
Copy link
Member Author

jklmnn commented Jun 16, 2020

@treiher can you please take a look at the failing check? I can't reproduce the issue locally (also I don't understand why it would fail there).

@treiher
Copy link
Collaborator

treiher commented Jun 17, 2020

I already observed that issue on the develop branch yesterday. I will look into it.

@treiher
Copy link
Collaborator

treiher commented Jun 17, 2020

The issue seems to be gone (on develop as well as on this branch). After re-running the tests other issues are found which seem to be related to your changes:

rflx-ipv4-tests.adb:320:07: medium: precondition might fail, cannot prove Field_Length (Ctx, F_Payload) mod 8 = 0

@jklmnn
Copy link
Member Author

jklmnn commented Jun 18, 2020

Fixed by #295.

@jklmnn jklmnn closed this as completed Jun 18, 2020
RecordFlux 0.4.1 automation moved this from In progress to Done Jun 18, 2020
@treiher treiher mentioned this issue Jul 14, 2020
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug generator Related to generator package (SPARK code generation)
Projects
No open projects
Development

No branches or pull requests

2 participants