delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/02/20/08:17:06

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:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; q=dns; s=default; b=J2
1/FwRmTO/Ir1V2r9BLy1FKLugxpq0tKl9z2N3yP2FnYDNHc8exu0dyjtNGksGD/g
aTbovQvduinuTJplGnaH+1sEMFOrIroGtU1RNa1CgyBMrp+cW0U9VqMmSVBA7z80
w/M5aFCSlc7XBtmkimu96nHdHuyVR0Hw5cMtDE2Pk=
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:mime-version:in-reply-to:references:date
:message-id:subject:from:to:content-type; s=default; bh=pJztzw40
ZhUbW1YrgofNsyIadeE=; b=SpUAZ3zwRuS4gFXvUUSKWSaNVA3WWCuwPVlPrGcS
DBgRQIhEEg8gvTUoCGf3CTSCVcRtseb8gSqoz8I1zF9BFR9xl2lQOZLqmt9+3a4G
h9ksOT147V3UFQX1ucsATIR/DPULd8o5MTGj84IxrGxmGqVqG6DJqzzoKvEkZBl3
A2E=
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
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2
X-HELO: mail-qc0-f178.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=Mws9fPZq3AnPlxKNPCkg2nu398x5iG8d/F2zMaywzTE=; b=jo0q2guJPihBzo48nETew5nhfu/oyOY0J5NofTNbSU3W8uca7jduSQ7KWnz4wUrjuN yTwXSRRKbhfsLjy8g9P1+f1ELxDWo+tLCd98fpoFo85dqVj+KsK1tICGGplpEUP8WLjZ 6crHbrbK6esWjx+CCT6GcXQq66n0Qv0xbOzYSMXwhDT+6Hpp/rSwaFhSNAWw7stZSv8J I9FGGs5WReovuwzAgGyFBTnFwoqLwPlWePI3lb9sJiciXBALumZs0sq8fdiRk+7dSdIb tTi9NtHrW1sLvjUSfmdbCB3UnW1JAbEyZ46XtEM9Gun0rWlEkfNgjFsEVDK432MKS6D4 hTpQ==
X-Gm-Message-State: ALoCoQk3oIAGinf7L4+x1J7z1iWRnhaYV1oO2K754PrGx5ROPsU0wKDY/rvP90yfUiqMX0cndE3L
MIME-Version: 1.0
X-Received: by 10.140.105.69 with SMTP id b63mr887374qgf.36.1392902204899; Thu, 20 Feb 2014 05:16:44 -0800 (PST)
In-Reply-To: <CAMzR4E7ngKr5HN=QEZXLUuy0VxGbD_xDN7UaTKPmfbmmD8Bz0A@mail.gmail.com>
References: <CAMzR4E7ngKr5HN=QEZXLUuy0VxGbD_xDN7UaTKPmfbmmD8Bz0A AT mail DOT gmail DOT com>
Date: Thu, 20 Feb 2014 14:16:44 +0100
Message-ID: <CAMzR4E6eO=m_s4+js=AA_EGntU=LRj9ZURmUqrwYqdVJ31hQWw@mail.gmail.com>
Subject: Re: Bug with dlopen() and fork()
From: Jaime Fabregas Fernandez <jaime DOT fabregas AT tarlogic DOT com>
To: cygwin AT cygwin DOT com

Hello Corinna,

As you've checked, this behaviour doesn't appear with dll's created by
gcc, but it does with Visual Studio C++.
That minimal example compiled with VS will result in the freeze of the
child process.

================ testlib.h ======================
#ifdef TESTLIB_EXPORTS
#define TEST_API extern "C" __declspec(dllexport)
#else
#define TEST_API extern "C" __declspec(dllimport)
#endif

TEST_API  int  mylib_open (const char *foo);
=============================================

=============== testlib.cpp ======================
#include "stdafx.h"
#include "testLib.h"

  int
  mylib_open (const char *foo)
  {
    return 1;
  }
==============================================

I've tested several compiler and linker options with same result.

Any ideas?

> On Feb 19 14:38, Jaime Fabregas Fernandez wrote:
>> Library references loaded by a process using dlopen() and dlsym() are
>> no more valid in child processes after running a fork(). Calls from
>> child process will never return.
>>
>> I've searched for a similar problem in the mailing lists and found
>> this unanswered thread from 2001:
>>
>> http://cygwin.com/ml/cygwin/2001-02/msg01225.html
>>
>>
>> I'm running cygwin64. This behaviour can be checked with the following
>> test program:
>>
>> ========================================================
>> #include <stdio.h>
>> #include <dlfcn.h>
>>
>> int (*myopen)(const char *);
>>
>> main(){
>>         void *handle;
>>         int ret;
>>         handle = dlopen("my_lib.dll", RTLD_LAZY);
>>         myopen = dlsym(handle, "mylib_open");
>>
>>         if( ! fork() ){
>>                 ret = myopen("");
>>                 printf("This printf never shows, call to myopen will
>> block for ever\n");
>>         }
>>         else{
>>                 ret = myopen("");
>>                 printf("%i\n", ret);
>>                 sleep(1);
>>         }
>> }
>> ========================================================
>>
>> Same program runs correctly (showing the two printf's) in a Linux environment.
>
> Works for me with 64 bit Cygwin.  I used this as DLL:
>
>   $ cat > my_lib.c <<EOF
>   int
>   mylib_open (const char *foo)
>   {
>     return 1;
>   }
>   $ gcc -shared -o my_lib.dll my_lib.c
>   $ gcc -g -o my_tst my_tst.c <- That's your above testcase
>   $ uname -a
>   CYGWIN_NT-6.3 vmbert8164 1.7.28(0.271/5/3) 2014-02-04 16:01 x86_64 Cygwin
>   $ ./my_tst
>   1
>   This printf never shows, call to myopen will block for ever
>   $
>
>
> 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

- Raw text -


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