Repository navigation
Fix header union member invalidation - #1478
Conversation
Invalidate the active union member even when setInvalid is called on an already-invalid sibling. Update target remove_header primitives to account for the active member's packet length, and copy only the active member in assign_union to preserve union assignment semantics. Add coverage for validity bits, repeated invalidation, union assignment and self-assignment, and simple_switch packet-length accounting. Companion to p4lang/p4c#4853; addresses the runtime side of p4lang/p4c#4448. Signed-off-by: fruffy <fruffy@nyu.edu>
Union assignments use assign_header, which reads the arithmetic value of each member field. Enable these values for union action and expression arguments, including members of union stacks, just as for header arguments. Add a JSON-loading regression that checks nonzero extracted fields referenced only through union arguments. Signed-off-by: fruffy <fruffy@nyu.edu>
Preserve whole-union assignments in BMv2 midends and encode local union references correctly. Keep CopyStructures constructor compatibility and tuple-copy behavior while fixing the stale configuration member. Pin the runtime fixes from p4lang/behavioral-model#1478 and remove the union-invalidation expected failures. Add packet coverage for local union copies, both active members, and an invalid source. Validated with BMv2 runtime suites, compiler and Testgen checks, eight Testgen STF cases, eight serial PTF cases, and the deterministic copy regression. Signed-off-by: fruffy <fruffy@nyu.edu>
jafingerhut
left a comment
There was a problem hiding this comment.
LGTM. I checked the changes carefully. I did not also carefully check for whether there are other places in the code that ought to be changed, but I expect if any remain, we would find them eventually in testing.
|
Claude says that this PR broke the From https://github.com/p4lang/p4c/actions/runs/42835177789/job/129895362272?pr=5876: CI p4c p4testgen failuresUser: @kfcripps @kfcrippsExplain why this job failed. CopilotThe "Run p4c tests (Docker image)" step failed. CTest exited with code 8 because 4 P4Testgen tests failed: Both The tail doesn't show the actual assertion/diff. Want me to pull the detailed failure output for one of these tests to pinpoint the root cause and work out a fix? @kfcrippsThis job is broken on main branch, so this PR did not cause it to fail. Please find out which PR broke the job and find the root cause. CopilotI'll investigate. Let me first pull the detailed failure output for one test, and look at the recent history on main for the failing tests. CTest output doesn't show per-test detail. Both failures are in STF and PTF backends (which actually run the generated packets through bmv2), while metadata/protobuf-ir backends pass. Let me look at recent main commits touching P4Testgen's STF/PTF code. Both failing programs involve header unions, and only STF/PTF (which run packets through bmv2) fail. Let me find when the container-image job first started failing on main. Key finding: the same commit The base image is Found the root cause. Let me confirm what bmv2 PR #1478 changed. Confirmed. Here's the diagnosis. Root cause: a behavioral-model (bmv2) change, not a p4c PRNo p4c PR broke this. The container-image job's own history proves it: the identical p4c commit The job rebuilds a Docker image from The breaking change is bmv2 PR #1478 "Fix header union member invalidation", merged That exactly explains the 4 failures, all header-union programs, and only in the STF/PTF backends (which actually execute packets through P4Testgen generates expected outputs modeling the old bmv2 union behavior, which no longer match the new runtime output → CTest exits with code 8. Likely fixThis is the runtime companion to p4c PR #4853. p4c's symbolic model of header-union invalidation must be updated to match bmv2's new spec-compliant semantics (and the two STF/PTF expected traces regenerated). Essentially p4c needs the matching #4853-side change merged/landed. Want me to pull the detailed STF diff for one test and draft the p4c-side fix (update the union invalidation model + regenerate expectations)? |
|
To unblock merging of P4C PRs, perhaps we should revert this PR, and then re-merge this PR after p4lang/p4c#4853 is approved and ready to be merged, so that p4lang/p4c#4853 can be merged immediately after, therefore minimizing the amount of time that the |
This reverts commit 5c72250. p4lang#1478 changed bmv2's header union invalidation semantics, which broke four P4Testgen STF/PTF tests in p4c's container-image CI job (built on p4lang/behavioral-model:latest). Revert it until the companion p4c change, p4lang/p4c#4853, is ready to land alongside it. Signed-off-by: Kyle Cripps <kyle@pensando.io>
@fruffy @jafingerhut If this is how you wish to proceed, then feel free to merge #1485 that I've just opened. Otherwise, let me know and I'll close it and let you resolve this in a different way. |
Invalidate the entire header union when
setInvalid()is called on any member, including an already-invalid member, as required by the P4 specification.remove_headerin simple_switch, psa_switch, and pna_nic to remove the active member and account for its packet length.assign_union, preserving valid copies and self-assignment under the corrected invalidation semantics.Companion to p4lang/p4c#4853; addresses the runtime side of p4lang/p4c#4448.