From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25223 invoked by alias); 14 Aug 2003 10:38:33 -0000 Mailing-List: contact pthreads-win32-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sources.redhat.com Received: (qmail 25163 invoked from network); 14 Aug 2003 10:38:25 -0000 Received: from unknown (HELO real.ise.canberra.edu.au) (137.92.140.34) by sources.redhat.com with SMTP; 14 Aug 2003 10:38:25 -0000 Received: from callisto.canberra.edu.au (special.ise.canberra.edu.au [137.92.140.39]) by real.ise.canberra.edu.au (8.11.6/8.11.6) with ESMTP id h7EAbvj24831 for ; Thu, 14 Aug 2003 20:38:12 +1000 Message-ID: <3F3B6678.7060401@callisto.canberra.edu.au> Date: Thu, 14 Aug 2003 10:38:00 -0000 From: Ross Johnson Reply-To: rpj@callisto.canberra.edu.au User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225 X-Accept-Language: en-us, en MIME-Version: 1.0 To: pthreads-win32@sources.redhat.com Subject: Reuse of Thread IDs Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003/txt/msg00069.txt.bz2 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