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: rego package panics when partial evaluation is executed with tracing enabled #2007

Closed
tsandall opened this issue Jan 16, 2020 · 1 comment · Fixed by #2011
Closed
Assignees
Labels

Comments

@tsandall
Copy link
Member

tsandall commented Jan 16, 2020

$ docker run openpolicyagent/opa:0.16.1 eval -p --explain=full 'data'
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/open-policy-agent/opa/rego.(*Rego).partial(0xc0001b8000, 0x10b5520, 0xc00002a030, 0xc0001dc000, 0x0, 0x0, 0x0)
	/src/rego/rego.go:1701 +0xbf0
github.com/open-policy-agent/opa/rego.PreparedPartialQuery.Partial(0xc0001b8000, 0xc000189ca0, 0x10b5520, 0xc00002a030, 0xc0001960e0, 0x1, 0x1, 0x0, 0x0, 0x0)
	/src/rego/rego.go:311 +0x170
github.com/open-policy-agent/opa/cmd.eval(0xc0001736e0, 0x1, 0x3, 0x100, 0xc0001882d0, 0x1, 0x1, 0x1627c90, 0x0, 0x0, ...)
	/src/cmd/eval.go:364 +0xe10
github.com/open-policy-agent/opa/cmd.init.3.func2(0xc00017c780, 0xc0001736e0, 0x1, 0x3)
	/src/cmd/eval.go:199 +0xde
github.com/spf13/cobra.(*Command).execute(0xc00017c780, 0xc000173680, 0x3, 0x3, 0xc00017c780, 0xc000173680)
	/src/vendor/github.com/spf13/cobra/command.go:766 +0x2ae
github.com/spf13/cobra.(*Command).ExecuteC(0x15c8520, 0x15c8520, 0xc0000bff88, 0x730d9f)
	/src/vendor/github.com/spf13/cobra/command.go:852 +0x2ec
github.com/spf13/cobra.(*Command).Execute(...)
	/src/vendor/github.com/spf13/cobra/command.go:800
main.main()
	/src/main.go:15 +0x32
@tsandall
Copy link
Member Author

@patrick-east can you take a look at this? It seems like some state is not being copied between the evaluation context and rego structures.

patrick-east added a commit to patrick-east/opa that referenced this issue Jan 16, 2020
There was a typo from a while back that caused problems with this. It
would only occur in cases where the Rego object was created without
tracers, prepared, and then partially evaluated with tracers supplied
as part of the evaluation context. Any of the other code paths would
actually work as the original Rego object would still have them and
the (wrong) reference wouldn't cause a panic.

At some point more recently we changed `opa eval` to split up its
options for the Rego object and evaluation. Doing this caused the
problem to surface when doing anything with `opa eval -p --explain ..`

Fixes: open-policy-agent#2007
Signed-off-by: Patrick East <east.patrick@gmail.com>
patrick-east added a commit that referenced this issue Jan 22, 2020
There was a typo from a while back that caused problems with this. It
would only occur in cases where the Rego object was created without
tracers, prepared, and then partially evaluated with tracers supplied
as part of the evaluation context. Any of the other code paths would
actually work as the original Rego object would still have them and
the (wrong) reference wouldn't cause a panic.

At some point more recently we changed `opa eval` to split up its
options for the Rego object and evaluation. Doing this caused the
problem to surface when doing anything with `opa eval -p --explain ..`

Fixes: #2007
Signed-off-by: Patrick East <east.patrick@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants