News for hackers. Stuff that matters.
Re:A 1.5GB String by ilyt on Saturday April 08, 2023 @10:40PM (#35499621)
That's a massive exaggeration. XML is both much more complex (and bug-prone) to parse, and wastes more space.

And the problem here wasn't JSON in the first place anyway, it was

> The “back” stack is unlimited, meaning we’re saving more and more state until we explode

And storing previous state in serialized string in current state, instead of just having it stored natively. You'd have same problem if you tried to serialize <format> into a field in <format>

Re:A 1.5GB String by userbinator on Saturday April 08, 2023 @11:05PM (#35499737)
You'd have same problem if you tried to serialize <format> into a field in <format>

Length-delimited formats don't need (exponentially increasing) escaping.

Re:A 1.5GB String by deepsun on Sunday April 09, 2023 @12:54AM (#35500164)
But why do you bring XML? The parent is against human-readable formats, and XML is one of them.
Re:A 1.5GB String by simplotek on Sunday April 09, 2023 @07:17AM (#35501643)
> And the problem here wasn't JSON in the first place anyway

Yes it was. They stored state in a huge JSON dump which ended up working like a zip bomb by the way they had to escape a string. This alone resulted in an exponential increase in memory that quickly became a problem.

Think about it for a second: would they experience this issue if they stored an in-memory stack per user? They wouldn't.

Heck, it seems that they could live with their JSON choice if they replaced '/' with any other inescapable character and converted it back to '/' when reading.

Re:A 1.5GB String by xigoi on Sunday April 09, 2023 @07:41AM (#35501790)
XML would also have a problem with this: you'd replace < with &lt;, then with &amp;lt;, then with &amp;amp;lt;, … It's not exponential, but still inefficient.
Re:A 1.5GB String by simplotek on Sunday April 09, 2023 @08:15AM (#35502011)
Inefficient is not the same as problematic. They turned what otherwise would be a linear increase in memory usage into an exponential increase, which expectedly resulted in memory exhaustion problems.

There are plenty of problems to go around this approach and overall system design, but the weakest link is undoubtedly how JSON was used.

Re:A 1.5GB String by jmull on Sunday April 09, 2023 @09:51AM (#35502728)
Can you imagine arguing in a tech meeting that a reason not to use JSON is that it doesn't support unbounded recursive levels of escaping very well?
Re:A 1.5GB String by ilyt on Monday April 10, 2023 @06:25AM (#35510810)
That is just entirely wrong; not serializing JSON into JSON would turn it back into linear.