cb424d7448
verify-patch-sanity.py validates every active recipe .patch has internally- consistent hunk line counts — catching the 'malformed patch at line N' failure at commit/CI/preflight time instead of hours into a cook. This cycle hit that class three times (qtwaylandscanner, sddm, xwayland), each only discovered when cookbook tried to apply the patch. Running it across the repo found 29 latent malformed patches (validated against GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22'). They were harmless only because they sit in vendored recipes (baked, not re- applied) — but would fail on any version-bump re-derivation. --fix recounts the hunk headers (body untouched) and repaired all 29. Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test (test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats (empty placeholders, bare-@@ git hunks).
50 lines
867 B
C++
50 lines
867 B
C++
// RUN: %clang_tsan -O1 %s -o %t && %deflake %run %t 2>&1 | FileCheck %s
|
|
|
|
#include <pthread.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <setjmp.h>
|
|
|
|
void bar(jmp_buf env) {
|
|
volatile int x = 42;
|
|
longjmp(env, 42);
|
|
x++;
|
|
}
|
|
|
|
void foo(jmp_buf env) {
|
|
volatile int x = 42;
|
|
bar(env);
|
|
x++;
|
|
}
|
|
|
|
__attribute__((noinline)) void badguy() {
|
|
pthread_mutex_t mtx;
|
|
pthread_mutex_init(&mtx, 0);
|
|
pthread_mutex_lock(&mtx);
|
|
pthread_mutex_destroy(&mtx);
|
|
}
|
|
|
|
__attribute__((noinline)) void mymain() {
|
|
jmp_buf env;
|
|
if (setjmp(env) == 42) {
|
|
badguy();
|
|
return;
|
|
}
|
|
foo(env);
|
|
fprintf(stderr, "FAILED\n");
|
|
}
|
|
|
|
int main() {
|
|
volatile int x = 42;
|
|
mymain();
|
|
return x;
|
|
}
|
|
|
|
// CHECK-NOT: FAILED
|
|
// CHECK: WARNING: ThreadSanitizer: destroy of a locked mutex
|
|
// CHECK: #0 pthread_mutex_destroy
|
|
// CHECK: #1 badguy
|
|
// CHECK: #2 mymain
|
|
// CHECK: #3 main
|
|
|