You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Anonymous-object formatting shares its recursion limit across threads #223
Formatting an anonymous object in one thread can replace an unrelated thread's output with "...". The recursion limit is shared by the entire process instead of tracking recursion within each formatting call chain.
Regression coverage first: test/regression/AnonConcurrentString in the existing Main.hx/build.hxml/stdout.txt layout. A worker formats a five-level anonymous object whose leaf toString signals a lock and waits. Once the worker reaches that leaf, the main thread formats a separate {x: 1} object and compares it with the same object's output before the worker started. Release the worker and wait for completion. All waits have deadlines.
Confirmed on Linux x86_64 with Haxe 4.3.3:
other thread preserves anon string: false
The unrelated small object formats as "..." while the worker is paused inside the nested formatting call. This reproduction deliberately coordinates the threads, so it does not require a probabilistic stress run.
src/hx/Anon.cpp declares a process-global static int _hx_toString_depth. Anon_obj::toString increments and decrements it around recursive formatting, returning "..." at depth 5. Each thread therefore consumes the same recursion budget. Uncoordinated simultaneous formatting also reads and modifies this plain integer without synchronization, which is an additional source-level race.
Keep recursion tracking local to the formatting thread or context, with exception-safe restoration. Preserve the existing bound for recursive values within one thread, and add a throwing custom toString case to check restoration.
This affects ordinary anonymous objects used in logs, diagnostics and data structures. It is separate from user objects deliberately returning "..." in their own toString. No runtime implementation changes are included.
Activity
Count anonymous-object formatting depth per thread