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

Compiler Bug: Null cst for InfInt Parameters #2354

Closed
fruffy opened this issue May 4, 2020 · 1 comment · Fixed by #2360
Closed

Compiler Bug: Null cst for InfInt Parameters #2354

fruffy opened this issue May 4, 2020 · 1 comment · Fixed by #2360
Assignees
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.

Comments

@fruffy
Copy link
Collaborator

fruffy commented May 4, 2020

New week, new bugs!

I was fuzzing integer types for a bit. The attached program crashes the type checker.
I also do not know if this is a legal construct, is it allowed to define a read-only parameter with type InfInt?

control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
    action do_action1(in int val) {
        bool test = 8w1 == val;
    }
    action do_action2(in int val) {
        h.eth_hdr.eth_type = h.eth_hdr.eth_type + val;
    }

    apply {
        do_action1(1);
        do_action2(1);
    }
}

type_checking_crash.p4.txt

@jafingerhut
Copy link
Contributor

I believe the compiler should give an error for this program, because type int is only allowed in places of a P4_16 program where it is limited to compile-time known values, and even though this particular program only ever calls the actions with those type int parameters with compile-time known values, I think that the intent is that the only kinds of parameters that can be type int are ones that the language always limits to compile-time known values, e.g. to constructor parameters for controls, parsers, and extern objects.

Even if I am correct that this program should cause an error, it should ideally not cause the compiler to crash as it does in my attempt to compiler it with this version of p4c:

$ p4c --version
p4c 1.2.0 (SHA: f6710f1a8)

$ p4c --target bmv2 --arch v1model type_checking_crash.p4.txt 
In file: /home/andy/p4c/frontends/p4/typeChecking/typeChecker.cpp:1546
Compiler Bug: /home/andy/p4c/frontends/p4/typeChecking/typeChecker.cpp:1546: Null cst

@mihaibudiu mihaibudiu self-assigned this May 4, 2020
@mihaibudiu mihaibudiu added bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed. labels May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This behavior is unintended and should be fixed. fixed This topic is considered to be fixed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants