Parse `content` with tree-sitter DIRECTLY in a forked child — bypassing * cbm_extract_file's Perl pre-parse nesting guard — returning true if the child * died by signal. This is the crash-isolating regression for the vendored GLR * stack-merge recursion cap (CBM_TS_STACK_MERGE_MAX_DEPTH, ts_runtime/src/stack.c): * the extract-level guard skips pathologically nested Perl before it reaches the
| 460 | * parser, so only a direct parse exercises the cap. Windows runs in-process (a |
| 461 | * real crash aborts the runner — a visible failure), mirroring so_extract_crashes. */ |
| 462 | static bool so_parse_crashes(const char *content, CBMLanguage lang) { |
| 463 | const TSLanguage *ts_lang = cbm_ts_language(lang); |
| 464 | if (!ts_lang) { |
| 465 | return false; |
| 466 | } |
| 467 | #if defined(_WIN32) |
| 468 | TSParser *parser = ts_parser_new(); |
| 469 | if (parser) { |
| 470 | ts_parser_set_language(parser, ts_lang); |
| 471 | TSTree *tree = ts_parser_parse_string(parser, NULL, content, (uint32_t)strlen(content)); |
| 472 | if (tree) { |
| 473 | ts_tree_delete(tree); |
| 474 | } |
| 475 | ts_parser_delete(parser); |
| 476 | } |
| 477 | return false; |
| 478 | #else |
| 479 | fflush(NULL); |
| 480 | pid_t pid = fork(); |
| 481 | if (pid < 0) { |
| 482 | return false; |
| 483 | } |
| 484 | if (pid == 0) { |
| 485 | /* Deterministic ceiling. Falsification data (2026-07-18, macOS |
| 486 | * ASan): with CBM_TS_STACK_MERGE_MAX_DEPTH deleted outright, this |
| 487 | * branch stayed GREEN both unbounded (220s full grind, no crash) |
| 488 | * and bounded — instrumentation shows the recursive merge path is |
| 489 | * never even entered here (max depth 0 through the whole window). |
| 490 | * The cap-regression DETECTION therefore lives in the Windows |
| 491 | * in-process branch above (real ~1 MB native stack, where #913 |
| 492 | * manifested); this POSIX branch is a bounded no-crash smoke of |
| 493 | * the pathological parse, and grinding past 10s adds no signal |
| 494 | * (unbounded it wandered 2s-218s with machine state). A real |
| 495 | * SIGSEGV/SIGBUS still terminates the child by signal before the |
| 496 | * alarm handler can exit cleanly. */ |
| 497 | signal(SIGALRM, so_parse_alarm_exit); |
| 498 | alarm(10); |
| 499 | TSParser *parser = ts_parser_new(); |
| 500 | if (parser) { |
| 501 | ts_parser_set_language(parser, ts_lang); |
| 502 | TSTree *tree = ts_parser_parse_string(parser, NULL, content, (uint32_t)strlen(content)); |
| 503 | if (tree) { |
| 504 | ts_tree_delete(tree); |
| 505 | } |
| 506 | ts_parser_delete(parser); |
| 507 | } |
| 508 | _exit(0); |
| 509 | } |
| 510 | int status = 0; |
| 511 | (void)waitpid(pid, &status, 0); |
| 512 | return WIFSIGNALED(status); |
| 513 | #endif |
| 514 | } |
| 515 | |
| 516 | TEST(lsp_java_deep_nesting_no_crash) { |
| 517 | /* Deeply nested call expressions — the same shape as the elasticsearch |
no test coverage detected