From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15773 invoked by alias); 23 Jul 2013 14:39:20 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 15764 invoked by uid 89); 23 Jul 2013 14:39:19 -0000 X-Spam-SWARE-Status: No, score=2.1 required=5.0 tests=AWL,BAYES_50,RDNS_NONE,URIBL_BLACK autolearn=no version=3.3.1 Received: from Unknown (HELO calimero.vinschen.de) (217.91.18.234) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 23 Jul 2013 14:39:18 +0000 Received: by calimero.vinschen.de (Postfix, from userid 500) id 940765209C2; Tue, 23 Jul 2013 16:39:10 +0200 (CEST) Date: Tue, 23 Jul 2013 15:13:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: Win32 error in C program using openmp and fork() Message-ID: <20130723143910.GI9689@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <57302C57257EF2428CCAAF9BA83EC0448222C0EA@mbx08.adf.bham.ac.uk> <20130722080657.GD2661@calimero.vinschen.de> <51EE7700.50803@star.sr.bham.ac.uk> <20130723130851.GG9689@calimero.vinschen.de> <20130723141855.GH9689@calimero.vinschen.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20130723141855.GH9689@calimero.vinschen.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2013-07/txt/msg00483.txt.bz2 On Jul 23 16:18, Corinna Vinschen wrote: > On Jul 23 15:08, Corinna Vinschen wrote: > > On Jul 23 13:28, Daniel Brown wrote: > > > and that still had the fork error. I have also tried running in safe > > > mode and > > > stopping all my anti-virus software just incase that was interfering > > > somehow. > > > So I get as an output now... > > > > > > Daniel@XPS15z ~ > > > $ uname -r > > > 1.7.22s(0.268/5/3) > > > > > > Daniel@XPS15z ~ > > > $ ./a.exe > > > I'm an openmp thread... > > > I'm an openmp thread... > > > I'm an openmp thread... > > > I'm an openmp thread... > > > Parent fork 1 [main] a 5832 C:\cygwin\home\Daniel\a.exe: *** fatal > > > error in forked process - failed > > > to create new win32 semaphore, currentvalue -2, Win32 error 87 > > > > > > However if I reduce the number of threads from 4 to 2 with: > > > > > > #pragma omp parallel num_threads(2) > > > { > > > printf("I'm an openmp thread...\n"); > > > } > > > > Ah, now there's something different. If I set the number of threads to > > 4, I can reproduce this problem almost every try with currentvalue -2, > > occassionally with currentvalue -1. > > > > > Looking at the source in thread.cc _fixup_after_fork() the win32 > > > error 87 is ERROR_INVALID_PARAMETER > > > which is due to currentvalue < 0. > > > > > > My only guess is that there is a race condition on the > > > currentvalue-- operations perhaps? > > > > Apparently. I investigate... > > Yes, there was a race condition in setting the value of the semaphore > private "currentvalue" member. The only reason to keep track of the > value is to allow _fixup_after_fork to set the right value, but here the > race comes into play. I redesigned this part so that it only sets > currentvalue once, right from fork itself, to propagate the correct > value to the child process. > > I'm just building new 32 and 64 bit snapshots. They should be available > on http://cygwin.com/snapshots/ in an hour at the latest. Please give > it a try. Both snapshots are up. Test away. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple