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

panic: parser accepts rule heads with key and args #2662

Closed
tsandall opened this issue Aug 26, 2020 · 0 comments
Closed

panic: parser accepts rule heads with key and args #2662

tsandall opened this issue Aug 26, 2020 · 0 comments
Assignees
Labels

Comments

@tsandall
Copy link
Member

The nightly fuzzer job found another panic:

package test

f(x)[x] { true }
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x834d68]

goroutine 1 [running]:
github.com/open-policy-agent/opa/ast.(*Compiler).compile.func1()
        /go/src/github.com/open-policy-agent/opa/ast/compile.go:881 +0x73
panic(0xbd4f20, 0x1319700)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
github.com/open-policy-agent/opa/ast.(*TypeEnv).Get(0xc0002f4200, 0xc6d700, 0x0, 0xdf0960, 0xc0002f1c80)
        /go/src/github.com/open-policy-agent/opa/ast/env.go:29 +0x58
github.com/open-policy-agent/opa/ast.(*typeChecker).checkRule(0xc0002f6120, 0xc0002f41f0, 0xc0000d1040)
        /go/src/github.com/open-policy-agent/opa/ast/check.go:174 +0x3a1
github.com/open-policy-agent/opa/ast.(*typeChecker).CheckTypes(0xc0002f6120, 0xc0002f41f0, 0xc0002f41c0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x8000101)
        /go/src/github.com/open-policy-agent/opa/ast/check.go:103 +0x168
github.com/open-policy-agent/opa/ast.(*Compiler).checkTypes(0xc0002e6000)
        /go/src/github.com/open-policy-agent/opa/ast/compile.go:845 +0x117
github.com/open-policy-agent/opa/ast.(*Compiler).runStage(0xc0002e6000, 0xcda3cd, 0x19, 0xc0001703a0)
        /go/src/github.com/open-policy-agent/opa/ast/compile.go:866 +0x46
github.com/open-policy-agent/opa/ast.(*Compiler).compile(0xc0002e6000)
        /go/src/github.com/open-policy-agent/opa/ast/compile.go:886 +0x125
github.com/open-policy-agent/opa/ast.(*Compiler).Compile(0xc0002e6000, 0xc00014d140)
        /go/src/github.com/open-policy-agent/opa/ast/compile.go:351 +0x2b4
...
@tsandall tsandall added the bug label Aug 26, 2020
@tsandall tsandall added this to TODO (Things That Should Be Done) in Open Policy Agent via automation Aug 26, 2020
tsandall added a commit to tsandall/opa that referenced this issue Aug 27, 2020
The parser was accepting rules that contained args and key terms in
the head. This was causing a panic during type checking because later
stages do expect this. This change just updates the parser to not emit
a rule in this case. Note, the parser was already dealing with this
correctly when the body was omitted.

Fixes open-policy-agent#2662

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
@tsandall tsandall moved this from TODO (Things That Should Be Done) to In Progress in Open Policy Agent Aug 27, 2020
@tsandall tsandall self-assigned this Aug 27, 2020
Open Policy Agent automation moved this from In Progress to Done Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

No branches or pull requests

1 participant