fix multiple bugs in SIGEV_THREAD timers

1. the thread result field was reused for storing a kernel timer id,
but would be overwritten if the application code exited or cancelled
the thread.

2. low pointer values were used as the indicator that the timer id is
a kernel timer id rather than a thread id. this is not portable, as
mmap may return low pointers on some conditions. instead, use the fact
that pointers must be aligned and kernel timer ids must be
non-negative to map pointers into the negative integer space.

3. signals were not blocked until after the timer thread started, so a
race condition could allow a signal handler to run in the timer thread
when it's not supposed to exist. this is mainly problematic if the
calling thread was the only thread where the signal was unblocked and
the signal handler assumes it runs in that thread.
This commit is contained in:
Rich Felker
2013-08-03 13:20:42 -04:00
parent 14012b91f2
commit 7356c2554e
6 changed files with 36 additions and 22 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ struct pthread {
void *pending;
} robust_list;
int unblock_cancel;
int delete_timer;
int timer_id;
locale_t locale;
int killlock[2];
int exitlock[2];