01mf02 / jaq

A jq clone focussed on correctness, speed, and simplicity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash when running simple example

cjappl opened this issue · comments

System: OSX
Version: jaq 1.2.0 (also tip of main b2a7f19)
Installed via: Brew (also tested on repo directly)

Steps to repro:

> echo '{"hi": 1}' | jq
{
  "hi": 1
}
> echo '{"hi": 1}' | jaq
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', jaq-interpret/src/filter.rs:227:16
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The full backtrace does not provide any more interesting information, it looks like:

> echo '{"hi": 1}' | jaq
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', jaq-interpret/src/filter.rs:
227:16
stack backtrace:
   0:        0x10320f0fc - __mh_execute_header
   1:        0x10321fb74 - __mh_execute_header
   2:        0x1031fe944 - __mh_execute_header
   3:        0x10320ef04 - __mh_execute_header

As a comment, but not a full explanation, the issue appears to be related to the processing of (absent) arguments:

$ echo 0 | jaq
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', jaq-interpret/src/filter.rs:227:16
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

$ echo 0 | jaq .
0

Interestingly, it looks like input processing happens before the command line is considered; we get more correctness in the error message when writing invalid JSON:

$ echo { | jaq
Error: failed to parse: value or end of sequence expected

(Interaction is identical with jaq ..)

This seems to be the same issue reported in #4. @01mf02 reported the upstream issue in ariadne, and they merged a PR (here). The issue should go away once they release a new version with the solution.

This is now corrected in #147.