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

Function extract_crashes

tests/test_lang_contract.c:228–254  ·  view source on GitHub ↗

Run cbm_extract_file in a forked child; return true if the child died from a * signal (SIGBUS/SIGSEGV/...). ASan does not install a SIGBUS handler, so an * in-process crash would terminate the whole test runner — forking isolates it * and lets us assert "extraction must not crash" deterministically. * * Windows (msys2) has no fork()/waitpid(): run in-process. A genuine crash there * aborts t

Source from the content-addressed store, hash-verified

226 * aborts the runner (a hard, visible failure), and the fork-isolated check still
227 * runs on the POSIX CI legs, so coverage is preserved. */
228static bool extract_crashes(const char *content, CBMLanguage lang, const char *relpath) {
229#if defined(_WIN32)
230 CBMFileResult *r =
231 cbm_extract_file(content, (int)strlen(content), lang, "lc", relpath, 0, NULL, NULL);
232 if (r) {
233 cbm_free_result(r);
234 }
235 return false;
236#else
237 fflush(NULL);
238 pid_t pid = fork();
239 if (pid < 0) {
240 return false; /* cannot fork — do not flag a crash we can't observe */
241 }
242 if (pid == 0) {
243 CBMFileResult *r =
244 cbm_extract_file(content, (int)strlen(content), lang, "lc", relpath, 0, NULL, NULL);
245 if (r) {
246 cbm_free_result(r);
247 }
248 _exit(0);
249 }
250 int status = 0;
251 (void)waitpid(pid, &status, 0);
252 return WIFSIGNALED(status);
253#endif
254}
255
256/* ══════════════════════════════════════════════════════════════════
257 * KNOWN-BUG CONTRACTS (must FAIL until fixed) — see P2

Callers 1

Calls 3

cbm_extract_fileFunction · 0.85
cbm_free_resultFunction · 0.85
_exitFunction · 0.85

Tested by

no test coverage detected