This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pthread_testcancel() causes SEGV


On Mon, 2002-09-16 at 19:07, Thomas Pfaff wrote:
> 
> 
> On Tue, 10 Sep 2002, Robert Collins wrote:
> 
> > On Thu, 2002-08-08 at 04:54, Jason Tishler wrote:
> > > Thomas,
> > >
> > > On Wed, Aug 07, 2002 at 09:34:14AM +0200, Thomas Pfaff wrote:
> > > > Thanks for tracking it down.
> > >
> > > No problem.  Thanks for the quick turn around on the patch.  I tested it
> > > and can confirm that it fixes the ipc-daemon service startup problem.
> >
> > Jason,
> > sorry for the *cough* long delay.
> >
> > the attached patch is the 'right way' to deal with this issue IMO. It
> > also gives us full pthread* support for threads created using the win32
> > CreateThread call (although I won't officially support that at this
> > point :}).
> >
> 
> Rob,
> 
> you may have noticed that i have added similar code in my pending pthread
> patches.

I hadn't actually. I simply started at the oldest pending thing, and
reviewed it.

> Anyway, since you return a NULL pointer in pthread_self if something went
> wrong i vote for inclusion of my original patch regardless which patch
> will be applied for pthread_self.

Ah, good catch. I'll return a null object instead.

This object will fail in the method call, and log an error. It shouldn't
segv though, and we won't be introducing a null object check that
doesn't need to exist.

I'm checking in the current code, as I refactored to make some things
clearer before I introduced the NULL object.

Attached is my test program for this..

Rob
#include <pthread.h>
#include <windows.h>


DWORD WINAPI
ThreadFunc (LPVOID lpParam)
{
  char szMsg[80];

  sprintf (szMsg, "Parameter = %d.", *(DWORD *) lpParam);
  // MessageBox (NULL, szMsg, "ThreadFunc", MB_OK);
  pthread_cancel(pthread_self());

  return 0;
}

int
main (VOID)
{
  DWORD dwThreadId, dwThrdParam = 1;
  HANDLE hThread;
  char szMsg[80];

  hThread = CreateThread (NULL,	// no security attributes 
			  0,	// use default stack size  
			  ThreadFunc,	// thread function 
			  &dwThrdParam,	// argument to thread function 
			  0,	// use default creation flags 
			  &dwThreadId);	// returns the thread identifier 

  // Check the return value for success. 

  if (hThread == NULL)
    {
      wsprintf (szMsg, "CreateThread failed.");
      MessageBox (NULL, szMsg, "main", MB_OK);
    }
  else
    {
      sleep(2);
      CloseHandle (hThread);
    }
}

Attachment: signature.asc
Description: This is a digitally signed message part


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]