This is the mail archive of the
pthreads-win32@sourceware.cygnus.com
mailing list for the pthreas-win32 project.
Bug in pthread_setcancelstate()?
- To: 'Pthreads-win32' <pthreads-win32 at sourceware dot cygnus dot com>
- Subject: Bug in pthread_setcancelstate()?
- From: Erik Hensema <erik dot hensema at group2000 dot nl>
- Date: Thu, 28 Oct 1999 16:53:18 +0200
Hi,
From the pthread_setcancelstate() from SunOS 5.5.1:
pthread_setcancelstate
pthread_setcancelstate() automically sets the calling
thread's cancellation state to the specified state and, if
oldstate is not NULL, stores the previous cancellation state
in oldstate.
In cancel.c:
if (((self = pthread_self ()) != NULL) &&
(state == PTHREAD_CANCEL_ENABLE ||
state == PTHREAD_CANCEL_DISABLE))
{
*oldstate = self->cancelState; <---- crash if oldstate==NULL
self->cancelState = state;
result = 0;
}
As you can see, it will crash if oldstate==NULL.
The obvious fix is to add the line " if(oldstate!=NULL)" above the
"*oldstate=".
ps. I haven't checked this with the Posix standard, so it can also be a
deviation from the standard by Sun; however, I think the code is more robust
this way.
--
Erik Hensema
Work: erik.hensema@group2000.nl
Home: erik@hensema.xs4all.nl