Shane McCarron
da046da59f
fix(ts-runtime): bound GLR stack-merge recursion to prevent stack overflow
...
tree-sitter's GLR parser merges ambiguous parse-stack heads recursively in
stack_node_add_link (internal/cbm/vendored/ts_runtime/src/stack.c), once per
nesting level. On pathologically nested input whose grammar is ambiguous
(Perl's paren-optional calls, f(f(f(...)))), that recursion overflows the
native stack during the parse — a small ~1 MB Windows thread stack, and even
an 8 MB POSIX stack at extreme depth — before any extraction runs. Grammars
that are unambiguous here (Java, C++) never trigger the recursive merge.
Cap the recursive merge at CBM_TS_STACK_MERGE_MAX_DEPTH (512) via a
depth-tracked inner worker; the public stack_node_add_link is a thin wrapper
seeding depth 0, so every existing call site is unchanged. Past the cap the
ambiguity is left on the GLR stack instead of merged — a valid parse, never a
wrong one. 512 frames is well within a 1 MB stack while far exceeding any
realistic source nesting.
Add perl_glr_deep_parse_recursion_capped: a crash-isolating regression that
parses deep ambiguous Perl directly (a forked child on POSIX, in-process on
Windows), bypassing cbm_extract_file's CBM_PERL_MAX_PARSE_NESTING pre-parse
guard so the vendored cap itself is exercised rather than the guard.
Narrow vendored-runtime change; no other parsing behavior is affected. The
higher-level Perl pre-parse guard (issue #913 context) stays in place and can
be retired in a follow-up once this cap is proven in the field.
Signed-off-by: Shane McCarron <shane.mccarron@corvexconnect.com >
2026-07-10 07:58:04 -05:00
..
2026-07-09 14:47:33 -05:00
2026-07-10 07:58:04 -05:00
2026-04-01 23:22:44 +02:00
2026-03-15 19:26:12 +01:00
2026-05-30 18:26:44 +02:00
2026-03-17 22:05:57 +01:00
2026-07-09 14:09:39 -05:00
2026-07-09 20:12:57 +02:00
2026-07-04 12:37:17 +09:00
2026-05-30 17:02:06 +02:00
2026-07-07 10:34:06 +02:00
2026-05-28 13:55:48 +02:00
2026-06-08 22:55:23 +02:00
2026-06-27 17:40:48 +02:00
2026-05-29 00:34:18 +02:00
2026-06-08 22:55:23 +02:00
2026-05-28 13:55:48 +02:00
2026-05-08 23:26:32 +02:00
2026-06-28 13:40:53 +02:00
2026-06-02 18:50:55 +02:00
2026-05-08 23:26:32 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-06-01 18:28:36 +02:00
2026-06-01 18:28:36 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-07 10:46:21 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-07 10:46:21 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-07 10:46:21 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-03-07 10:46:21 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-07-01 20:17:11 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-05-09 11:50:05 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-06-01 18:07:05 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-04-15 21:28:51 +02:00
2026-03-07 18:01:27 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-03-05 22:39:01 +01:00
2026-04-15 21:28:51 +02:00
2026-06-28 18:47:39 +02:00
2026-06-28 18:47:39 +02:00
2026-07-08 00:05:19 +05:30
2026-06-22 19:56:46 -04:00
2026-07-09 14:09:39 -05:00
2026-04-01 23:22:44 +02:00
2026-03-15 19:26:12 +01:00
2026-03-13 00:07:28 +01:00
2026-03-15 19:26:12 +01:00
2026-07-07 11:33:56 +08:00
2026-07-07 11:33:56 +08:00
2026-07-03 20:16:39 +02:00
2026-07-03 20:16:39 +02:00
2026-03-05 22:39:01 +01:00
2026-07-07 20:41:06 +02:00
2026-07-07 20:41:06 +02:00