MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / so_parse_crashes

Function so_parse_crashes

tests/test_stack_overflow.c:461–513  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 1

Calls 1

cbm_ts_languageFunction · 0.85

Tested by

no test coverage detected