Jean Boussier 8e8e327870 [ruby/json] Fix concurrent usage of JSON::Coder#dump
Fix: 90616277e3 (r168784389)

Because the `depth` counter is inside `JSON::State` it can't be used
concurrently, and in case of a circular reference the counter may be
left at the max value.

The depth counter should be moved outside `JSON_Generator_State` and
into `struct generate_json_data`, but it's a larger refactor.

In the meantime, `JSON::Coder` calls `State#generate_new` so I changed
that method so that it first copy the state on the stack.

https://github.com/ruby/json/commit/aefa671eca
2025-10-25 08:57:48 +00:00
..