infix
A JIT-Powered FFI Library for C
|
A cross-platform test for thread-safety issues using Valgrind's Helgrind tool or other thread sanitizers. More...
#include "common/double_tap.h"
#include "common/infix_config.h"
#include <infix/infix.h>
#include <stdbool.h>
#include <pthread.h>
#include <stdint.h>
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 | |
A cross-platform test for thread-safety issues using Valgrind's Helgrind tool or other thread sanitizers.
Copyright (c) 2025 Sanko Robinson
This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.
SPDX-License-Identifier: (Artistic-2.0 OR MIT)
The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).
SPDX-License-Identifier: CC-BY-4.0
This test is designed to be run specifically under thread analysis tools. It creates multiple threads that concurrently generate, use, and destroy FFI reverse trampolines (callbacks). The tool will analyze the execution for potential data races and other synchronization errors in the underlying library code.
This version of the test is structured to be free of data races in the test code itself. All reporting is done by the main thread after all worker threads have completed. Therefore, a successful run should produce ZERO errors from the analysis tool. Any reported error indicates a genuine thread-safety bug within the infix library.
#define DBLTAP_IMPLEMENTATION |
#define ITERATIONS_PER_THREAD 500 |
#define NUM_THREADS 8 |
void helgrind_test_handler | ( | int | a, |
int | b | ||
) |
void * helgrind_thread_worker | ( | void * | arg | ) |
subtest | ( | "Thread-safety stress test" | ) |