1 // -*- C++ -*- 2 //===----------------------------------------------------------------------===// 3 // 4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5 // See https://llvm.org/LICENSE.txt for license information. 6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7 // 8 //===----------------------------------------------------------------------===// 9 10 // REQUIRES: linux && target={{aarch64-.+}} 11 12 // pthread_cancel in case of glibc calls _Unwind_ForcedUnwind from a signal on 13 // the child_thread. This test ensures sigretrun is handled correctly (see: 14 // UnwindCursor<A, R>::setInfoForSigReturn). 15 16 #include <chrono> 17 #include <condition_variable> 18 #include <pthread.h> 19 #include <unistd.h> 20 21 using namespace std::chrono_literals; 22 23 std::condition_variable cv; 24 std::mutex cv_m; 25 bool thread_ready = false; 26 27 static void* test(void* arg) { 28 (void)arg; 29 thread_ready = true; 30 cv.notify_all(); 31 32 // This must be a pthread cancellation point. 33 while (1) 34 sleep(100); 35 36 return (void*)1; 37 } 38 39 int main() { 40 pthread_t child_thread; 41 std::unique_lock<std::mutex> lk(cv_m); 42 pthread_create(&child_thread, 0, test, (void*)0); 43 44 if (!cv.wait_for(lk, 100ms, [] { return thread_ready; })) 45 return -1; 46 47 pthread_cancel(child_thread); 48 pthread_join(child_thread, NULL); 49 return 0; 50 } 51