fix multiple bugs in SIGEV_THREAD timers
commit7356c2554e33cf16768616e8e3ae4a4f5a5aac17
authorRich Felker <dalias@aerifal.cx>
Sat, 3 Aug 2013 17:20:42 +0000 (3 13:20 -0400)
committerRich Felker <dalias@aerifal.cx>
Sat, 3 Aug 2013 17:20:42 +0000 (3 13:20 -0400)
tree9510cb631685508d9ece852b7ce865e91a903589
parent14012b91f2b52f70fd3f3bb807fb880654337da5
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.
src/internal/pthread_impl.h
src/time/timer_create.c
src/time/timer_delete.c
src/time/timer_getoverrun.c
src/time/timer_gettime.c
src/time/timer_settime.c