public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
* Reuse of Thread IDs
@ 2003-08-14 10:38 Ross Johnson
  0 siblings, 0 replies; only message in thread
From: Ross Johnson @ 2003-08-14 10:38 UTC (permalink / raw)
  To: pthreads-win32

Hi all,

Nicolas Barry has discovered that a couple of routines 
(pthread_getschedparam etc) had rather iffy thread validation checks 
that could ultimately segfault due to pthread_t being a simple pointer 
to alloced memory that was being freed on thread exit. This weakness in 
the library hasn't been entirely unanticipated though, but it's time has 
arrived.

These routines also returned an incorrect error value (EINVAL instead or 
ESRCH).

As a result, I've changed the way that threads are managed slightly.

The validation check is now stronger and goes as far as checking the 
validity of the underlying Win32 thread HANDLE stored in the POSIX 
thread handle. To make work, the library (as of the current CVS version) 
now no longer frees pthread structs when a thread exits. Instead it 
pushes disused structs onto a LIFO stack (implemented as a simple 
guarded linked list). Thread handles are still calloced if no disused 
handles are available.

There is now also an exported pthread_kill() routine, but it only 
accepts a zero value for the signal arg. Any other value will return 
EINVAL. It's intended to be used by applications that want to test the 
validity of a POSIX thread handle (as intended by the standard).

I've added a few more tests to the test suite, and the library passes 
all of the tests so hopefully these changes will be pretty transparent 
to your applications. I hope to get a new snapshot out soon, with 
pre-built DLLs and libs as usual.

I've also made changes that fix a number of problems that came up when I 
changed to using the current MinGW + MsysDTK environment.

Regards.
Ross


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-08-14 10:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-14 10:38 Reuse of Thread IDs Ross Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).