You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
int g_thread_run = 1;
pthread_mutex_t mutex;
pthread_cond_t cond;
int g_signal_count = 0;
void sig_handler(int signum) {
write(0, "sig\n", 4);
__sync_fetch_and_add(&g_signal_count, 1);
}
void* my_thread(void* arg) {
pthread_mutex_lock(&mutex);
while (g_thread_run) {
pthread_cond_wait(&cond, &mutex);
}
pthread_mutex_unlock(&mutex);
return NULL;
}
int main(int argc, char**argv) {
signal(SIGUSR1, &sig_handler);
pthread_t thr;
pthread_create(&thr, NULL, &my_thread, NULL);
sleep(1); // wait for thread to get inside pthread_cond_wait
pthread_kill(thr, SIGUSR1);
while (__atomic_load_n(&g_signal_count, __ATOMIC_SEQ_CST) == 0) {
;
}
pthread_mutex_lock(&mutex);
g_thread_run = 0;
pthread_cond_signal(&cond);
pthread_mutex_unlock(&mutex);
void* ret;
pthread_join(thr, &ret);
return 0;
}
What is the expected output? What do you see instead?
todd@todd-ThinkPad-T540p:/tmp$ /home/todd/sw/clang-230631-2/bin/clang -o test test.c
-lpthread
todd@todd-ThinkPad-T540p:/tmp$ time ./test
sig
real 0m1.001s
user 0m0.000s
sys 0m0.001s
todd@todd-ThinkPad-T540p:/tmp$ /home/todd/sw/clang-230631-2/bin/clang -o test -fsanitize=thread
test.c -lpthread
todd@todd-ThinkPad-T540p:/tmp$ time ./test
<hangs forever>
What version of the product are you using? On what operating system?
todd@todd-ThinkPad-T540p:/tmp$ /home/todd/sw/clang-230631-2/bin/clang -v
clang version 3.7.0 (trunk 230631)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/4.8.1
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
(from the chromium toolchain)
Please provide any additional information below.
Reported by tlipcon on 2015-04-08 04:29:17
The text was updated successfully, but these errors were encountered:
Should actually rephrase the title a bit -- the signal does arrive, but only after pthread_cond_wait
returns. It looks like the pthread_cond_wait interceptor is missing a wrapping 'BlockingCall'
scope, perhaps?
Originally reported on Google Code with ID 91
Reported by
tlipcon
on 2015-04-08 04:29:17The text was updated successfully, but these errors were encountered: