From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23045 invoked by alias); 12 Dec 2006 12:27:25 -0000 Received: (qmail 23036 invoked by uid 22791); 12 Dec 2006 12:27:23 -0000 X-Spam-Check-By: sourceware.org Received: from py-out-1112.google.com (HELO py-out-1112.google.com) (64.233.166.180) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 12 Dec 2006 12:27:19 +0000 Received: by py-out-1112.google.com with SMTP id p76so1376588pyb for ; Tue, 12 Dec 2006 04:27:16 -0800 (PST) Received: by 10.35.101.1 with SMTP id d1mr14910912pym.1165926436180; Tue, 12 Dec 2006 04:27:16 -0800 (PST) Received: by 10.35.11.8 with HTTP; Tue, 12 Dec 2006 04:27:16 -0800 (PST) Message-ID: <321e820c0612120427t6cff8a59h35eb5fde17a7506f@mail.gmail.com> Date: Tue, 12 Dec 2006 12:27:00 -0000 From: "Sergey Fokin" To: pthreads-win32@sourceware.org Subject: Pthread-win32 races? MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact pthreads-win32-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: pthreads-win32-owner@sourceware.org X-SW-Source: 2006/txt/msg00071.txt.bz2 Hi all. I have some peculiarities with pthread-win32 and suppose there's a bug in library. Here's my example code: #include #include #include #include void * thr(void * arg) { sem_post((sem_t*)arg); return 0; } int main() { sem_t sem; int error = 0; error = sem_init(&sem, 0, 0); // OK assert(!error); pthread_t thread; error = pthread_create(&thread, 0, thr, &sem); // OK assert(!error); sem_wait(&sem); error = sem_destroy(&sem); if (error != 0) { error = errno; // errno == 16 (EBUSY) printf("errno = %d\n", error); } pthread_join(thread, 0); return error; } So, here we have error 16 (0x10) in almost all runs, independently on compile options (at least i couldn't find working combination). Compiler is msvc 7.1 sp1. I've read about some troubles with it in BUGS file, but first, this one is unrelated to those, as I can see, second all tests from `tests' directory run with no errors, but this one fails even with same compile options. When I've tried to debug, it turned out that when main() is executing sem_destroy(), child thread is still in sem_post(). But I couldn't find out what's going on there and supposed this is some kind of race, this is why subject is about races. Google didn't find similar issues about pthread-win32 library. Really hope, this is my fault, but I have no idea where I'm wrong. Thanks in advance. PS I'll also try gcc for win32 and msvc8.0 later - I don't have them on this computer. -- eof