-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Particular test asserts path_len == 0
, but only with run-tests
#1875
Comments
Fascinating! Thanks for the report! |
Ah, yes, the issue is that the test did not consume enough outputs from the jq state machine. There's a bug there, but it only affects tests, at least in this case.
The issue has to do with the argument to I would have expected that this jq program would exercise the bug, |
The jq processor in the co-routines branch is susceptible:
And you can see it's the
The simplest thing to do may be to remove the assertion and replace it with resetting
That patch removes the immediate problem, and I think it's sound (but we should reason about that). |
BTW, AFL is awesome. I do really need to learn how to use it. Thanks @pallas! |
Expressions of the form `path(EXPR) | select(GENERATOR)`, where `EXPR` is a path expression and `GENERATOR` is a generator conditional expression (e.g., `has("a"), has("b")`) cause an assertion if the jq_state VM is torn down too soon. That assert() was only correct if assuming that the conditional is not a generator. If the conditional is generator, then what we see is that when backtracking a SUBEXP_END is executed without a corresponding SUBEXP_BEGIN because the entire conditional is bracketed with SUBEXP_BEGIN and SUBEXP_END, and since it's resumed in the middle, in between the brackets. Rather than assert that the jq->path_len being restored has some particular value, we can simply re-compute it from the restored jq->path.
Describe the bug
With run-tests, the following test asserts.
It does not fail outside of run-tests, e.g. with
echo '[1,2,3]' | jq 'path(.[] | select(.,3))'
To Reproduce
See above.
Expected behavior
No assert.
Environment (please complete the following information):
Additional context
Found by American Fuzzy Lop, based on the following testsuite test.
The text was updated successfully, but these errors were encountered: