49 lines · cpp
1// RUN: %clangxx -fsanitize=realtime %s -o %t2// RUN: %run %t 2>&1 | FileCheck %s3 4// UNSUPPORTED: ios5 6// Intent: Ensures that pthread_cond_signal does not segfault under rtsan7// See issue #1461208 9#include <condition_variable>10#include <future>11#include <mutex>12#include <thread>13 14#include <iostream>15 16int main() {17 std::cout << "Entry to main!" << std::endl;18 19 20 // TODO: This is disabled because it does cause a test failure21 /*22 std::mutex mut;23 std::condition_variable cv;24 bool go{false};25 26 const auto fut = std::async(std::launch::async, [&] {27 std::this_thread::sleep_for(std::chrono::milliseconds(100));28 {29 std::unique_lock<std::mutex> lock(mut);30 go = true;31 }32 cv.notify_one();33 });34 35 std::unique_lock<std::mutex> lock(mut);36 // normal wait is fine37 // cv.wait(lock, [&] { return go; });38 // but timed wait could segfault39 40 // NOTE: When a fix for the pthread_cond issue #146120 is fixed, uncomment this line41 //cv.wait_for(lock, std::chrono::milliseconds(200), [&] { return go; });42 */43 44 std::cout << "Exit from main!" << std::endl;45}46 47// CHECK: Entry to main!48// CHECK-NEXT: Exit from main!49