www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2013/07/23/08:29:21

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
q=dns; s=default; b=X3uDLjwdnSDjtcuFqtrxJ93nugPKoV/U8j95SfACwim
DVmicT4m6zAOihwTm4m3SOyUorbHXUp/eMPeMaDYn43jOrRt4UhLCLtRygi/6GXy
kefJj+CIIm1EDmsSny9Up9jzgR//Ohjt6Jy9xJASKB1nMbG/OWA7C63UmT8Uirpo
=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:message-id:date:from:mime-version:to:subject
:references:in-reply-to:content-type:content-transfer-encoding;
s=default; bh=FygLbHvCMl3S+hQHLJm2nHvDE1A=; b=bewR8IfkCha9zLW7F
ZFI4zz+EzJsu2qZRpEmc/Qjox2NGwdz0peFqpbZzbXce2leawS8QpKpBFFbB1D3L
HwYCM3ztBpyRUk1xnGgpKH2AlgNpj697OITBQEGjvyf45Qj0olc3XAVtn3r6fk9r
QJsr+8BgopsxsQ6ngMqhjKaegs=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Spam-SWARE-Status: No, score=4.5 required=5.0 tests=AWL,BAYES_50,KHOP_RCVD_UNTRUST,KHOP_THREADED,RCVD_IN_DNSWL_MED,RCVD_IN_HOSTKARMA_W,RDNS_NONE autolearn=ham version=3.3.1
Message-ID: <51EE7700.50803@star.sr.bham.ac.uk>
Date: Tue, 23 Jul 2013 13:28:48 +0100
From: Daniel Brown <ddb AT star DOT sr DOT bham DOT ac DOT uk>
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Win32 error in C program using openmp and fork()
References: <57302C57257EF2428CCAAF9BA83EC0448222C0EA AT mbx08 DOT adf DOT bham DOT ac DOT uk> <20130722080657 DOT GD2661 AT calimero DOT vinschen DOT de>
In-Reply-To: <20130722080657.GD2661@calimero.vinschen.de>

I've wiped my old version of Cygwin and installed it fresh on my computer
and 1.7.21 doesn't work for me, either 32 or 64 bit. I have tried a Win 
7 x86
virtual machine and it worked, on a Win 8 x86 virtual machine though I see
the same error. Therefore I guess it is a Windows 8 issue unless you are
running it?

I tried replacing the cygwin1.dll with the latest snapshots 1.7.22s x86
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 AT XPS15z ~
$ uname -r
1.7.22s(0.268/5/3)

Daniel AT 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");
}

it works fine, if I use 3 threads then the error comes back. 
Interestingly the the value of currentvalue
changes each time I run the program if I use 4 or more threads, if I use 
3 then it is always -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?

Thanks,
Daniel

On 22/07/2013 09:06, Corinna Vinschen wrote:
> On Jul 20 19:30, Daniel Brown wrote:
>> Hi,
>>
>> So I have some code I am trying to port to Cygwin but I am getting the
>> error:
>>
>> fatal error in forked process - failed to create new win32 semaphore,
>> Win32 error 87
>>
>> when calling fork() in a C program when openmp code has been used
>> beforehand. I've got the following test code which reduces the problem
>> down to as little code as I could:
>>
>> #include <stdio.h>
>> #include <omp.h>
>> #include <sys/types.h>
>>
>> int main(void)
>> {
>>       pid_t childPID;
>>
>>       #pragma omp parallel
>>       {
>>           printf("I'm an openmp thread...\n");
>>       }
>>
>>       childPID =3D fork();
>>
>>       if(childPID >=3D 0) {
>>           if(childPID =3D=3D 0) {
>>               printf("Child fork\n");
>>           } else {
>>               printf("Parent fork\n");
>>           }
>>       } else {
>>           printf("Fork failed");
>>           return 1;
>>       }
>>
>>       return 0;
>> }
>>
>> To build I just use "gcc -fopenmp para.c" and the output I get is...
>>
>> I'm an openmp thread...
>> I'm an openmp thread...
>> I'm an openmp thread...
>> I'm an openmp thread...
>> Parent fork 0 [main] a 18640 D:\usr\code\c\a.exe: *** fatal error
>> in forked process - failed to create new win32 semaphore, Win32 error
>> 87
> I didn't try with 1.7.20, but with the current 1.7.21 and with the
> latest snapshot from http://cygwin.com/snapshots/, on 32 and 64 bit,
> and this is what I get on both cases:
>
>    $ uname -r
>    1.7.21(0.267/5/3)
>    $ gcc -g -fopenmp -o openmp-test openmp-test.c
>    $ ./openmp-test
>    I'm an openmp thread...
>    I'm an openmp thread...
>    Parent fork
>    Child fork
>    $
>
>
> Corinna
>


--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019