-
Notifications
You must be signed in to change notification settings - Fork 445
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
BMV2 backend generates no errors for hash input expressions it can't handle #430
Comments
If @antoninbas can confirm this diagnosis it should be relatively easy to fix this in the compiler. |
I can confirm this. I updated the bmv2 JSON parser to throw an error in this case (p4lang/behavioral-model#322). |
I can confirm the problem with
In both cases expression type element is generated, but in the case of digest, running generated JSON in BMV2 ends up with SIGABRT due to assertion.
But during my experiments, I have found another weird behaviour of
|
I think that the P4-14 spec was never clear about this fact, but actually the digest is given a reference to a field list, and the digest always executes at the end of the pipeline. In P4-16 there are no references, so this kind of behavior is impossible to express in the language. By using a fresh temporary the compiler can implement the "eager" semantics. We have a problem with regards to P4-14 programs; when translating them to P4-16 we can implement either semantics (delayed evaluation or immediate evaluation) by playing with temporaries. There may be additional difficulties related to the control-plane API of the digest primitive; this is also not clearly specified. |
The PR above fixes the "complex expression" problem, but it does not fix the weird semantics for digest. Unfortunately our testing framework does not support digest, so we can't write a test for this issue. |
* Final fix for issue #430 * bug fix
According JSON input format BMV2 does not accept expressions as an input for hash calculations. However, no error is generated if you use an expression it can't handle; the result is just silent failure. BMV2 does not output any error with the generated JSON, but the output value of the hash is always zero regardless the input.
An example of a code:
Relevant fragment of the generated JSON:
The text was updated successfully, but these errors were encountered: