Phase 29: add project benchmarks, endurance stress and callback safety checks

This commit is contained in:
Johannes Findeisen 2026-10-27 17:07:37 +01:00
commit afc049e2c8
14 changed files with 1032 additions and 43 deletions

View file

@ -6,12 +6,37 @@
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
void *__real_malloc(size_t size);
void *__real_calloc(size_t count, size_t size);
void *__real_realloc(void *pointer, size_t size);
void __real_free(void *pointer);
static int processing, fail_after = -1;
/* Catch direct host I/O and blocking synchronization in guarded callbacks.
* Dynamic dependencies have their own symbols and are outside this audit. */
FILE *__real_fopen(const char *path, const char *mode);
size_t __real_fread(void *buffer, size_t size, size_t count, FILE *file);
size_t __real_fwrite(const void *buffer, size_t size, size_t count, FILE *file);
ssize_t __real_read(int fd, void *buffer, size_t size);
ssize_t __real_write(int fd, const void *buffer, size_t size);
int __real_pthread_mutex_lock(pthread_mutex_t *mutex);
int __real_pthread_cond_wait(pthread_cond_t *condition, pthread_mutex_t *mutex);
FILE *__wrap_fopen(const char *path, const char *mode)
{ assert(!processing); return __real_fopen(path, mode); }
size_t __wrap_fread(void *buffer, size_t size, size_t count, FILE *file)
{ assert(!processing); return __real_fread(buffer, size, count, file); }
size_t __wrap_fwrite(const void *buffer, size_t size, size_t count, FILE *file)
{ assert(!processing); return __real_fwrite(buffer, size, count, file); }
ssize_t __wrap_read(int fd, void *buffer, size_t size)
{ assert(!processing); return __real_read(fd, buffer, size); }
ssize_t __wrap_write(int fd, const void *buffer, size_t size)
{ assert(!processing); return __real_write(fd, buffer, size); }
int __wrap_pthread_mutex_lock(pthread_mutex_t *mutex)
{ assert(!processing); return __real_pthread_mutex_lock(mutex); }
int __wrap_pthread_cond_wait(pthread_cond_t *condition, pthread_mutex_t *mutex)
{ assert(!processing); return __real_pthread_cond_wait(condition, mutex); }
static unsigned int prepared, destroyed;
static int fail_allocation(void)
{