zserge / jsmn

Jsmn is a world fastest JSON parser/tokenizer. This is the official repo replacing the old one at Bitbucket
MIT License
3.65k stars 778 forks source link

Parse output error on Mac. #137

Open Ulmo opened 6 years ago

Ulmo commented 6 years ago

Here's a jsondump parse output error on Mac that I don't get on Linux:

Source file:

curl.txt

Here is the buggy output on Mac:

curl-bug-out.txt

Here is what the output should look like, what it does look like under Linux, and what it looks like afetr I hacked a bug fix for Mac that works in my application into it:

curl-out-correct.txt

I was able to hack a fix for it on Mac in my small application by replacing BUFSIZ with (16384) on line 69 of jsondump.c since my files are under 4K. Obviously the buffer read error bug is still there, and should be fixed, but doesn't affect me right now.

I think #125 might be related.

Addendum:

I just tested BUFSIZ in my Linux and on my Mac. In Linux, BUFSIZ is 8192, and on Mac, BUFSIZ is 1024. This is clearly the source of the bug since my input file is 2,436 bytes long, so it requires multiple buffers in Mac.

This is the sort of bug I am really good at fixing in flow programs, but I don't have time right now since I fixed it for my application and I'm busy on other things.