pthreads works, sorta

Robert Collins
Tue Jun 26 22:58:00 GMT 2001

> -----Original Message-----
> From: Dmitry Timoshkov [ ]
> Sent: Wednesday, June 27, 2001 4:51 PM
> To: Robert Collins; Greg Smith;
> Subject: Re: pthreads works, sorta
> "Robert Collins" <> wrote:
> [skipped]
> > What does all this mean? We need to catch invalid memroy access, and
> > ValidQuery was supplied by Chris as a tool to do that.
> In a multithreaded environment VirtualQuery, IsBad* and 
> similar approaches
> are wrong. It can't be guaranteed that after a successful 
> test that memory
> will be still accessable.

It's kernel allocated memory we are checking against (the user cannot
free it from under us). The function does the following:
check the pointer is not null
check the pointer is into mapped address space.
check the type of the structure it's pointing into is correct (ie a
thread object).

The main reason for the readable address check is to prevent the process
hanging because a signal is generated in cygwin's pthread code due to
bad userland variable values (threads are used to handle signals and
thus signals from the pthreads code never gets processed). The race
protection is dealt with (not completely yet) elsewhere.

I agree with the principle that you describe however.
> > So the question for all the win32 gurus:
> > 
> > Whats a fast way to catch (in-cygwin-dll) invalid memory 
> access's. Can
> > we use structed exception handling there? Or...?
> Using SEH is probably a way to go.

SEH uses pthreads in multithreaded applications. Will SEH work reliably
in the pthreads code? 


> --
> Dmitry.
> --
> Unsubscribe info:
> Bug reporting:
> Documentation:
> FAQ:         

Unsubscribe info:
Bug reporting:

More information about the Cygwin mailing list