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

Potential failing range checks not detected in model #317

Open
treiher opened this issue Jul 1, 2020 · 0 comments
Open

Potential failing range checks not detected in model #317

treiher opened this issue Jul 1, 2020 · 0 comments
Labels
generator Related to generator package (SPARK code generation) model Related to model package (e.g., model verification)

Comments

@treiher
Copy link
Collaborator

treiher commented Jul 1, 2020

We are unable to detect potential failing range checks in the model. Here is an example:

package Test is

   type A is mod 2 ** 32;

   type B is
      message
         C : A
            then D
               with Size => C * 8;
         D : Opaque;
      end message;

end Test;
rflx-test-generic_b.adb:78:72: medium: range check might fail, in instantiation at rflx-test-b.ads:6
rflx-test-generic_b.adb:97:56: medium: range check might fail, in instantiation at rflx-test-b.ads:6
 78                    Types.Bit_Length (Ctx.Cursors (F_C).Value.C_Value) * 8,
[...]
 96   function Field_Last (Ctx : Context; Fld : Field) return Types.Bit_Index is
 97     (Field_First (Ctx, Fld) + Field_Length (Ctx, Fld) - 1);

Bit_Length is defined as follows by default:

   type Length is new Natural;
   type Bit_Length is range 0 .. Length'Last * 8;

But a user is able to use a custom buffer type with another value range for its index (the upper limit of Index and Length must be equal). So I doubt we will be able to completely prevent such cases by adding a check to the model.

@treiher treiher added generator Related to generator package (SPARK code generation) model Related to model package (e.g., model verification) limitation labels Jul 1, 2020
@treiher treiher mentioned this issue Jul 1, 2020
26 tasks
@treiher treiher added the v0.4.1 label Jul 14, 2020
@treiher treiher added the v0.5.0 label Jul 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generator Related to generator package (SPARK code generation) model Related to model package (e.g., model verification)
Projects
None yet
Development

No branches or pull requests

2 participants