Summary: | pthread_atfork() missing from libc_r | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | mikko <mikko> | ||||
Component: | bin | Assignee: | Jason Evans <jasone> | ||||
Status: | Closed FIXED | ||||||
Severity: | Affects Only Me | ||||||
Priority: | Normal | ||||||
Version: | 5.0-CURRENT | ||||||
Hardware: | Any | ||||||
OS: | Any | ||||||
Attachments: |
|
Description
mikko
2000-03-17 18:30:02 UTC
Responsible Changed From-To: freebsd-bugs->jasone Over to maintainer. (Following up on myself after further investigations): Nope, the above patch is insufficient, it only serves to uncover other bugs. The problem is that libc_r does not do complete cleanup of the other threads after the fork. All deleted threads must be quietly removed from any queues they happen to be waiting in, or they may later be subject to "revival" after they have been freed. Scenario (typical use of pthread_atfork()): - forking thread aquires a number of mutexes. - another thread waits on one of the mutexes - after forking, the mutexes are released, which will make any waiting threads runnable -- but they have been deallocated! - Bad Things(tm) happen... All mutexes where this may happen can be conveniently located via the "mutexq" field of the running thread, so this particular scenario is easily fixed. There is no similar way to handle threads queued on, for example, condition variables, as there is no way to find the head of the "qe" and "pqe" queue entries. The "join_queue" should be emptied too. Basically, right now libc_r does not work at all after a fork(). Regards, /Mikko State Changed From-To: open->closed There is no plan to add pthread_atfork(), due to the difficulty and limited usefulness of doing so. |