This is the mail archive of the mailing list for the pthreas-win32 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]

Reuse of Thread IDs

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.


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