Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Just recently V8 the JS engine rewrote their JSON parsing code to achieve upto 2.7x faster parsing and also making it memory efficient.

Ref link:- https://v8.dev/blog/v8-release-76



Ah, so that's the source of that Chrome bug that we saw last week. Customers on Chrome for Windows (only that, not Chrome for Linux or macOS) were complaining that the search on our statically-generated documentation site was not working. The search is implemented by a JavaScript file that downloads a JSON containing a search index, and it turns out that this search index had too much nesting for Chrome on Windows's JSON parser. This would reliably produce a stack overflow:

  JSON.parse(Array(3000).join('[')+Array(3000).join(']'))
We were about to report a bug when we noticed that the problem was fixed in Chrome 76, and the users in question were still on Chrome 75.


Pretty weird for a JSON parser to be platform dependent.


Not really, parsing JSON is probably a recursive algorithm and Windows gives processes way less stack space than Linux (generally 1MB vs 8MB). It could totally be that the code is the same, but the particular JSON string blows up the stack in Windows but not Linux.


Maybe the stack is shallower on Windows, or the calling convention takes more space per function and is enough to push it over the edge.


Recursion based implementation of parsers in languages with limited stack size is a programmer mistake.


All languages have limited stack size.


Eh... not really if you're referring to call stacks. Rust at one point had growable stacks. That was removed for performance reasons. Haskell with GHC kind of has growable stacks (basically IIRC most function calls occur on the heap) and its stack overflows take a different form. SML I think at one point also had an implementation with a growable call stack.


I guess this is a nitpick of limited vs. fixed. Even if you grow the stack, at some point you can't grow anymore.


If by limited you mean limited by the amount of memory your machine has then yes it's limited, but I don't think that's what parent was getting at, since in that sense everything about a computer is limited.


If your C/C++ code calls functions, it's platform dependent in this way. C doesn't provide a lot of guarantees wrt minimum stack size.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: