delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2014/07/07/09:58:36

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; q=dns; s=default; b=Bmbi+L
ot5r0DJkI4O4EF9tG5IWDyfQoWrhdgNOCMUwpUNidBD+LiwJIBienoEvoVROF681
KBCGg5aRLPnbOlMh6rxm5GkHs9rIyRRxNJEL5/EOUKKeMsbLoWNGIFPYkXBIWbpx
BNB9CLizmM0u4BmIaN+Pen2XA4xpakCs0fsMc=
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; s=default; bh=oMumiGO4ytlR
OYHCPyRcmAWgMsU=; b=xqildLlMGo4vbXuMb/ewX/eKmRxtWFR1mMddblM+5f6t
VTzbTFafZrJDZGJ9Bl1sySpMgIo8vTHQBKkN4ojnPmeExr+34E+c+yR8LIM8jihH
5s9nupZZXToXEdHkWUiwyRUHVo98tCEArKbolnz7zWlwF2xzWxlsaJnyUvzH9Os=
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=-0.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2
X-HELO: rgout02.bt.lon5.cpcloud.co.uk
X-CTCH-RefID: str=0001.0A090206.53BAA774.00BA,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0
X-Junkmail-Premium-Raw: score=28/50,refid=2.7.2:2014.7.7.105419:17:28.394,ip=86.177.101.223,rules=__MOZILLA_MSGID, __HAS_MSGID, __SANE_MSGID, __HAS_FROM, __USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION, __TO_MALFORMED_2, __TO_NO_NAME, __BOUNCE_CHALLENGE_SUBJ, __BOUNCE_NDR_SUBJ_EXEMPT, __SUBJ_ALPHA_END, __IN_REP_TO, __CT, __CTYPE_HAS_BOUNDARY, __CTYPE_MULTIPART, __CTYPE_MULTIPART_MIXED, __BAT_BOUNDARY, __ANY_URI, URI_ENDS_IN_HTML, __CP_URI_IN_BODY, __SUBJ_ALPHA_NEGATE, __FORWARDED_MSG, BODYTEXTP_SIZE_3000_LESS, BODY_SIZE_3000_3999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, __URI_NS, SXL_IP_DYNAMIC[223.101.177.86.fur], HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, RDNS_SUSP, BODY_SIZE_7000_LESS, MIME_TEXT_ONLY_MP_MIXED
X-CTCH-Spam: Unknown
Message-ID: <53BAA770.7070005@dronecode.org.uk>
Date: Mon, 07 Jul 2014 14:58:08 +0100
From: Jon TURNEY <jon DOT turney AT dronecode DOT org DOT uk>
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: abort during exit() with a dynamically loaded C++ library
References: <53A084E7 DOT 9010807 AT dronecode DOT org DOT uk>
In-Reply-To: <53A084E7.9010807@dronecode.org.uk>

--------------070102050805060806020100
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 17/06/2014 19:11, Jon TURNEY wrote:
> I think I have found a problem when building programs using the latest
> mesa library, where abort is being called during exit()
>
> This seems to be x86 specific, and looks like it is somehow related to
> having a C++ library dynamically loaded by a C program.
>
> I think I have reduced it to the following test case:

So, this seems to be related to this patch [1], to fix a different abort 
during __gcc_deregister_frame()

[1] https://sourceware.org/ml/cygwin/2013-07/msg00528.html

Since this code is baked into libgcc itself, that patch has the 
side-effect of making libgcc pin itself in memory.

I can't really tell from what's written there if that was deliberate or 
not, but it seems that it introduces a different problem when the 
executable doesn't have a dependency on libgcc.

> test.c:
>
> #include <assert.h>
> #include <dlfcn.h>
>
> int main()
> {
>     void *h = dlopen("dllib.dll", 0);
>     assert(h);
>     dlclose(h);

The problem can be worked around by adding code to force libgcc to get 
unloaded here, which seems to support this theory, e.g.

+#define LIBGCC_SONAME "cyggcc_s-1.dll"
+   HANDLE hmod_libgcc = GetModuleHandle(LIBGCC_SONAME);
+   FreeLibrary(hmod_libgcc);

> }

Attached is a patch which modifies __gcc_register_frame() to avoid it 
pinning itself in memory.

Alternatively, as one of the emails in the linked thread says [2], the 
assert in __deregister_frame_info_bases() itself could be removed.

[2] http://www.mail-archive.com/gcc AT gcc DOT gnu DOT org/msg68286.html


--------------070102050805060806020100
Content-Type: text/plain; charset=windows-1252;
 name="cygming-crtbegin.c.patch"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
 filename="cygming-crtbegin.c.patch"

LS0tIGN5Z21pbmctY3J0YmVnaW4uYy5iYWsJMjAxNC0wNy0wMyAxNjo0MTo0
My4xMTY2MDAwMDAgKzAxMDAKKysrIGN5Z21pbmctY3J0YmVnaW4uYwkyMDE0
LTA3LTAzIDE4OjM5OjA3LjQzNjgwMDAwMCArMDEwMApAQCAtOTksOCArOTks
MjEgQEAKIAogICBpZiAoaCkKICAgICB7Ci0gICAgICAvKiBJbmNyZWFzaW5n
IHRoZSBsb2FkLWNvdW50IG9mIExJQkdDQ19TT05BTUUgRExMLiAgKi8KLSAg
ICAgIG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CSAgR2V0UHJvY0FkZHJlc3MgKGgsICJfX3JlZ2lzdGVyX2ZyYW1lX2lu
Zm8iKTsKICAgICB9Cg==


--------------070102050805060806020100
Content-Type: text/plain; charset=us-ascii

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

- Raw text -


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