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
| 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. */ |
| 228 | static 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 |
no test coverage detected