infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
820_threading_helgrind.c File Reference

A stress test to detect data races and other threading issues. More...

#include "common/double_tap.h"
#include "common/infix_config.h"
#include <infix/infix.h>
#include <stdbool.h>
#include <pthread.h>
#include <stdint.h>
Include dependency graph for 820_threading_helgrind.c:

Macros

#define DBLTAP_IMPLEMENTATION
 
#define NUM_THREADS   8
 
#define ITERATIONS_PER_THREAD   500
 

Functions

void helgrind_test_handler (int a, int b)
 
void * helgrind_thread_worker (void *arg)
 
 subtest ("Thread-safety stress test")
 

Variables

 TEST
 

Detailed Description

A stress test to detect data races and other threading issues.

This test is designed to be run with a thread sanitizer tool, such as Valgrind's Helgrind or GCC/Clang's -fsanitize=thread (TSan). Its purpose is to verify that the infix library's use of thread-local storage (TLS) for error handling and other contexts is correct and free of data races.

The test spawns multiple threads, and each thread independently runs a tight loop of creating, using, and destroying infix trampolines.

A "pass" for this test is not just that the program completes successfully, but that the thread sanitizer tool reports zero data races or other synchronization errors. This is critical for ensuring that infix is safe to use in multi-threaded applications.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

◆ ITERATIONS_PER_THREAD

#define ITERATIONS_PER_THREAD   500

◆ NUM_THREADS

#define NUM_THREADS   8

Function Documentation

◆ helgrind_test_handler()

void helgrind_test_handler ( int  a,
int  b 
)

◆ helgrind_thread_worker()

void * helgrind_thread_worker ( void *  arg)

◆ subtest()

subtest ( "Thread-safety stress test"  )

Variable Documentation

◆ TEST

TEST
Initial value:
{
plan(1)
#define plan(count)
Definition double_tap.h:163