Skip to content

Commit cc704f4

Browse files
committed
fix: TSan 下跳过 OpenMP 扩展性测试,消除 libomp 运行时误报
ThreadSanitizer 报告 OpenMPScalingTests.ParallelForEfficiency 存在数据 竞争,但竞争双方均在 libomp.so.5 内部(pthread_mutex_lock vs pthread_mutex_init),属于 OpenMP 运行时与 TSan 的已知不兼容,并非 reduction 本身的真实竞争。在 TSan 下跳过该测试,保留 asan/ubsan 及 同文件其他并发测试的覆盖。
1 parent ff73a64 commit cc704f4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

tests/property/concurrency_properties.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,14 @@ TEST(LockFreeQueueTests, EmptyQueuePop) {
450450
* Validates: Requirements 5.4, 5.5
451451
*/
452452
TEST(OpenMPScalingTests, ParallelForEfficiency) {
453-
#ifndef _OPENMP
453+
#if !defined(_OPENMP)
454454
GTEST_SKIP() << "OpenMP not available";
455+
#elif (defined(__has_feature) && __has_feature(thread_sanitizer)) || defined(__SANITIZE_THREAD__)
456+
// The OpenMP runtime (libomp) is not TSan-instrumented: its internal
457+
// pthread_mutex_init/lock during thread-pool fork-join surface as
458+
// false-positive data races. The reduction itself is race-free.
459+
GTEST_SKIP() << "OpenMP runtime (libomp) is not TSan-instrumented; "
460+
"internal mutex races are false positives under TSan";
455461
#else
456462
constexpr size_t N = 10000000;
457463
std::vector<double> data(N);

0 commit comments

Comments
 (0)