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
The native render path crashes on a small thread when a Vue component's data nests deeply #398
A component that uses Vue, with data nested a few hundred levels deep, crashes the process when it renders on a thread with a small stack and the native render path is on (the default). For example, 100 nested <div c-for="rowN in rows"> elements, rendered in a thread started after threading.stack_size(512 * 1024), which is the macOS default for threads other than the main one:
with the native path on, the process exits with SIGILL and no Python traceback;
with CITRY_NATIVE_RENDER=0, the same render succeeds;
with a 2 MiB thread, both succeed.
This was measured with a debug build of citry-core on macOS arm64, on the branch for #387, which guards the Vue compiler and the server renderer. A release build has smaller frames, so its crash depth is higher, but it is not measured.
Why
write_value in crates/citry_core_py/src/native_render/leaf_json.rs writes a leaf's Python values as JSON. It calls itself once per nested dict, list or tuple, up to its own limit of 200 levels (MAX_DEPTH). Each level reads Python objects through PyO3, so the stack guard the Rust crates use (stacker) cannot help here. CPython 3.14 and later check the stack pointer against the thread's own stack, and a heap segment is outside it.
Possible fix
Make write_value iterative: keep the open containers and their iterators on an explicit stack, so the number of Rust frames stays the same at any depth. The output and the declines (too_deep, cycle, not_plain) stay exactly as they are.
Activity