Patch-ID# 100983-03
Keywords: libthread SIG_DFL EINTR timeout cond_timedwait
Synopsis: SunOS 5.2: fixes for usr/lib/libthread
Date: Jan/21/94

Solaris Release: 2.2

SunOS release: 5.2

Unbundled Product:

Unbundled Release:

Topic: SunOS 5.2: fixes for usr/lib/libthread

BugId's fixed with this patch: 1114100 1117554 1125344 1134191 1146922

Changes incorporated in this version: 1146922

Relevant Architectures: sparc

Patches accumulated and obsoleted by this patch: 101101-01

Patches which conflict with this patch:

Patches required with this patch:

Obsoleted by:

Files included with this patch:

usr/lib/libthread.so.1
usr/lib/libthread_db.so.0
usr/lib/libthread_db.a

Problem Description:

1146922 cond_timedwait() misses its timeout and hangs


The cond_timedwait() interface doesn't reliably guarentee that a thread
will wakeup even if it has specified a timeout period.

Also, its possible for signals to be pending on a thread which are never
delivered.


(from 100983-02)


If an MT application has short-lived threads, or threads at different
priorities, it is possible for a thread which is blocked in a system call
to get preempted. The existence of short-lived threads would cause the reaper
to wake up more frequently increasing the possibility of preemption.
The threads library sends SIGLWP to a thread to preempt it. 
The threads library system call wrappers should block SIGLWP to prevent
the receipt of SIGLWP from interrupting such a system call. The bug was
that the wrappers did not mask SIGLWP, due to which preemption, hence SIGLWP,
interrupted system calls.


(from 100983-01)

This patch is necessary to support all the correct UNIX signal semantics with
respect to signal masking and the SIG_DFL disposition in a multi-threaded (MT)
process. The specific bugs in these areas are detailed in the report on 
bugids 1114100 and 1117554, and arise due to the fact that the MT signal
model implements thread signal masks at the user-level. These masks are not 
visible to the kernel.

Note: This patch preserves the performance advantages of having a 2-level
signal mask, which allows a multi-threaded process to mask signals
without entering the kernel, providing an extremely fast signal masking
implementation. This allows applications to create cheap async-safe
critical sections.

The other bug fix in this patch is unrelated to the fixes for the MT signal
model. Internally, in the threads library, when a bound thread exits, it
switches to a small stack just before exiting. After the stack switch, it
is a bug for the dynamic linker to be invoked, which would overflow the small
stack. The bug manifests itself as corruption of data that is in memory
contiguous to that from which the small stack is allocated.





Patch Installation Instructions:
--------------------------------
Generic 'installpatch' and 'backoutpatch' scripts are provided
within each patch package with instructions appended to this section.
Other specific or unique installation instructions may also be
necessary and should be described below.

Special Install Instructions:
----------------------------- 

None.





