aboutsummaryrefslogtreecommitdiff
path: root/src/thread/__set_thread_area.c (unfollow)
Commit message (Expand)AuthorFilesLines
2011-08-02fix stubbed-out reboot callRich Felker1-3/+2
2011-08-02correctly handle old kernels without FUTEX_WAIT_BITSET•••futex returns EINVAL, not ENOSYS, when op is not supported. unfortunately this looks just like EINVAL from other causes, and we end up running the fallback code and getting EINVAL again. fortunately this case should be rare since correct code should not generate EINVAL anyway. Rich Felker1-1/+1
2011-08-02fix sem_timedwait bug introduced in timedwait unification•••this dec used to be performed by the cancellation handler, which was called when popped. Rich Felker1-0/+1
2011-08-02unify and overhaul timed futex waits•••new features: - FUTEX_WAIT_BITSET op will be used for timed waits if available. this saves a call to clock_gettime. - error checking for the timespec struct is now inside __timedwait so it doesn't need to be duplicated everywhere. cond_timedwait still needs to duplicate it to avoid unlocking the mutex, though. - pushing and popping the cancellation handler is delegated to __timedwait, and cancellable/non-cancellable waits are unified. Rich Felker10-53/+56
2011-08-02avoid accessing mutex memory after atomic unlock•••this change is needed to fix a race condition and ensure that it's possible to unlock and destroy or unmap the mutex as soon as pthread_mutex_lock succeeds. POSIX explicitly gives such an example in the rationale and requires an implementation to allow such usage. Rich Felker4-34/+31
2011-08-02fix breakage in cancellation due to signal functions overhaul•••sigaddset was not accepting SIGCANCEL as a valid signal number. Rich Felker1-1/+7
2011-08-02overhaul posix semaphores to fix destructability race•••the race condition these changes address is described in glibc bug report number 12674: http://sourceware.org/bugzilla/show_bug.cgi?id=12674 up until now, musl has shared the bug, and i had not been able to figure out how to eliminate it. in short, the problem is that it's not valid for sem_post to inspect the waiters count after incrementing the semaphore value, because another thread may have already successfully returned from sem_wait, (rightly) deemed itself the only remaining user of the semaphore, and chosen to destroy and free it (or unmap the shared memory it's stored in). POSIX is not explicit in blessing this usage, but it gives a very explicit analogous example with mutexes (which, in musl and glibc, also suffer from the same race condition bug) in the rationale for pthread_mutex_destroy. the new semaphore implementation augments the waiter count with a redundant waiter indication in the semaphore value itself, representing the presence of "last minute" waiters that may have arrived after sem_post read the waiter count. this allows sem_post to read the waiter count prior to incrementing the semaphore value, rather than after incrementing it, so as to avoid accessing the semaphore memory whatsoever after the increment takes place. a similar, but much simpler, fix should be possible for mutexes and other locking primitives whose usage rules are stricter than semaphores. Rich Felker3-27/+23
2011-08-01fix wrong messages in gai_strerror•••i had missed the fact that a couple values were unassigned... Rich Felker1-0/+2
2011-08-01port numbers should always be interpreted as decimal•••per POSIX and RFC 3493: If the specified address family is AF_INET, AF_INET6, or AF_UNSPEC, the service can be specified as a string specifying a decimal port number. 021 is a valid decimal number, therefore, interpreting it as octal seems to be non-conformant. Rich Felker1-1/+1
2011-08-01fix crash in dns code with new stdio locking codeRich Felker1-0/+1
2011-07-31consistency: use struct __ucontext instead of ucontext_t in prototypes•••this is necessary to avoid build errors if feature test macros are not properly defined when including ucontext.h Rich Felker1-1/+1
2011-07-30fix race condition in sigqueue•••this race is fundamentally due to linux's bogus requirement that userspace, rather than kernelspace, fill in the siginfo structure. an intervening signal handler that calls fork could cause both the parent and child process to send signals claiming to be from the parent, which could in turn have harmful effects depending on what the recipient does with the signal. we simply block all signals for the interval between getuid and sigqueue syscalls (much like what raise() does already) to prevent the race and make the getuid/sigqueue pair atomic. this will be a non-issue if linux is fixed to validate the siginfo structure or fill it in from kernelspace. Rich Felker1-2/+8
2011-07-30clean up pthread_sigmask/sigprocmask dependency order•••it's nicer for the function that doesn't use errno to be independent, and have the other one call it. saves some time and avoids clobbering errno. Rich Felker2-11/+7
2011-07-30fix some bugs in setxid and update setrlimit to use __synccall•••setrlimit is supposed to be per-process, not per-thread, but again linux gets it wrong. work around this in userspace. not only is it needed for correctness; setxid also depends on the resource limits for all threads being the same to avoid situations where temporarily unlimiting the limit succeeds in some threads but fails in others. Rich Felker2-10/+33
2011-07-30add proper fuxed-based locking for stdio•••previously, stdio used spinlocks, which would be unacceptable if we ever add support for thread priorities, and which yielded pathologically bad performance if an application attempted to use flockfile on a key file as a major/primary locking mechanism. i had held off on making this change for fear that it would hurt performance in the non-threaded case, but actually support for recursive locking had already inflicted that cost. by having the internal locking functions store a flag indicating whether they need to perform unlocking, rather than using the actual recursive lock counter, i was able to combine the conditionals at unlock time, eliminating any additional cost, and also avoid a nasty corner case where a huge number of calls to ftrylockfile could cause deadlock later at the point of internal locking. this commit also fixes some issues with usage of pthread_self conflicting with __attribute__((const)) which resulted in crashes with some compiler versions/optimizations, mainly in flockfile prior to pthread_create. Rich Felker20-46/+71
2011-07-30eliminate dependence of perror on printfRich Felker1-10/+5
2011-07-30fix bug in synccall with no threads: lock was taken but never releasedRich Felker1-4/+4