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

jq -ar reports malloc error #1763

Open
itchyny opened this Issue Nov 8, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@itchyny

itchyny commented Nov 8, 2018

Describe the bug
jq 1.6 using -a and -r flag reports a malloc error, which I believe should not occur.

To Reproduce

 $ echo '{"foo":[{"name":"bar"},{"name":"baz"}]}' | jq -ar ".foo[].name"
"bar"
jq(71775,0x7fffa1105380) malloc: *** error for object 0x7fd5fee00c30: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
zsh: done       echo '{"foo":[{"name":"bar"},{"name":"baz"}]}' |
zsh: abort      jq -ar ".foo[].name"

Expected behavior
No malloc error.

Environment (please complete the following information):

  • OS and Version: macOS
  • jq version: 1.6
 $ jq -V
jq-1.6
 $ shasum `which jq`
cd805c2856b38b8040547de9675cd33ab1713c92  /usr/local/bin/jq

Additional context
With jq 1.5 the malloc error does not happen.

@pkoppstein

This comment has been minimized.

Contributor

pkoppstein commented Nov 8, 2018

I believe the problem was introduced in bf88c73

Using the immediately preceding version:

$ ./jq --version
jq-1.6rc1-7-gae11f11-dirty

$ echo '{"foo":[{"name":"bar"},{"name":"baz"}]}' | ./jq -ar ".foo[].name"
bar
baz
@leonid-s-usov

This comment has been minimized.

leonid-s-usov commented Nov 8, 2018

I believe the problem was introduced in ae11f11
that commit looks like a documentation typo fix. Are you sure it's related?

@pkoppstein

This comment has been minimized.

Contributor

pkoppstein commented Nov 8, 2018

@leonid-s-usov - You're right - I made an off-by-one error and have fixed the SHA-1. Thanks.

@leonid-s-usov

This comment has been minimized.

leonid-s-usov commented Nov 8, 2018

Cool, this makes it trivial to fix the issue - added a comment there on the line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment