X-Recipient: archive-cygwin@delorie.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
	:content-type:content-transfer-encoding; q=dns; s=default; b=OIl
	edq7JXjudbGXGnpi3nOCrGvEey9IZRm0nmY9heZVYTiTYUy4Z/iyKw6HVrnmqXeh
	v3/XGPqdz8Ct0EJTb8RfCX6vNJCjHFOa2CVXVWrelY9HVTUkRd/ULL8imiMMkRti
	EbqVFWgjuSPvDu5zGAlf9orVcdq0RC7BqjYwtIFo=
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
	:content-type:content-transfer-encoding; s=default; bh=1hBvrKnPf
	fnoLjWiVITXKml3GYg=; b=WnJY4oQ/JNmytPRNTeVeDRWi/En/YXiBloND4gbTp
	J4cqCyzzohBdki91B9J7tRdKCRGD14YV9KgkXTD+XtAQt2AWYU9At4p8D4srSonr
	ptbql41wfmR7mz5qD4ZzbYCjDp3YjTu9b8lna5ZmB+EdveJX++Ytn19svDi7G16V
	L4=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2
X-HELO: rgout03.bt.lon5.cpcloud.co.uk
X-CTCH-RefID: str=0001.0A090204.53A084F2.0097,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0
X-Junkmail-Premium-Raw: score=27/50,refid=2.7.2:2014.6.17.151520:17:27.888,ip=86.179.19.114,rules=__MOZILLA_MSGID, __HAS_MSGID, __SANE_MSGID, __HAS_FROM, __USER_AGENT, __MOZILLA_USER_AGENT, __MIME_VERSION, __TO_MALFORMED_2, __TO_NO_NAME, __SUBJ_ALPHA_START_END, __SUBJ_ALPHA_START, __SUBJ_ALPHA_END, __CT, __CT_TEXT_PLAIN, __CTE, BODY_SIZE_3000_3999, __MIME_TEXT_ONLY, RDNS_GENERIC_POOLED, SXL_IP_DYNAMIC[114.19.179.86.fur], HTML_00_01, HTML_00_10, BODY_SIZE_5000_LESS, RDNS_SUSP_GENERIC, RDNS_SUSP, BODY_SIZE_7000_LESS, NO_URI_FOUND
X-CTCH-Spam: Unknown
Message-ID: <53A084E7.9010807@dronecode.org.uk>
Date: Tue, 17 Jun 2014 19:11:51 +0100
From: Jon TURNEY <jon.turney@dronecode.org.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@cygwin.com
Subject: abort during exit() with a dynamically loaded C++ library
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit


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:

test.c:

#include <assert.h>
#include <dlfcn.h>

int main()
{
    void *h = dlopen("dllib.dll", 0);
    assert(h);
    dlclose(h);
}

dllib.c:

#include <fstream>

std::fstream instance;

Makefile:

all:
         g++ -g -O0 -c dllib.cc
         g++ -g -O0 -shared -o dllib.dll dllib.o
         gcc -g -O0 -o test.exe test.c
         ./test


Running under gdb shows gcc_abort() in __deregister_frame_info_bases() 
is being hit

$ gdb test
[...]
Program received signal SIGABRT, Aborted.
0x0028da18 in ?? ()
(gdb) bt
#0  0x0028da18 in ?? ()
#1  0x74f912cc in WriteFile () from 
/cygdrive/c/Windows/syswow64/kernel32.dll
#2  0x610da70c in sig_send(_pinfo*, siginfo_t&, _cygtls*)@12 
(p=p@entry=0x60fd0000, si=..., tls=tls@entry=0x0)
     at /usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/sigproc.cc:638
#3  0x610d7dbc in _pinfo::kill(siginfo_t&)@8 (this=0x60fd0000, si=...)
     at /usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/signal.cc:248
#4  0x610d8286 in kill0 (pid=pid@entry=5044, si=...) at 
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/signal.cc:299
#5  0x610d8452 in kill (sig=sig@entry=6, pid=5044) at 
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/signal.cc:308
#6  raise (sig=sig@entry=6) at 
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/signal.cc:284
#7  0x610d86f3 in abort () at 
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/signal.cc:371
#8  0x699134d1 in __deregister_frame_info_bases (begin=0x404038 
<__EH_FRAME_BEGIN__>)
     at /usr/src/debug/gcc-4.8.3-1/libgcc/unwind-dw2-fde.c:216
#9  0x00401182 in __gcc_deregister_frame ()
#10 0x61006466 in do_global_dtors () at 
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/dcrt0.cc:62
#11 0x61159aba in __call_exitprocs (code=code@entry=0, d=d@entry=0x0)
     at 
/usr/src/debug/cygwin-1.7.30-1/newlib/libc/stdlib/__call_atexit.c:118
#12 0x611305d8 in exit (code=0) at 
/usr/src/debug/cygwin-1.7.30-1/newlib/libc/stdlib/exit.c:66
#13 0x61006b39 in cygwin_exit (n=0) at 
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/dcrt0.cc:1248
#14 0x61008041 in cygwin_exit_return () at 
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/dcrt0.cc:1041
#15 0x61005e84 in _cygtls::call2(unsigned long (*)(void*, void*), void*, 
void*)@16 (this=<optimized out>,
     func=func@entry=0x610071d0 <dll_crt0_1(void*)>, arg=arg@entry=0x0, 
buf=buf@entry=0x28cd84)
     at /usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/cygtls.cc:100
#16 0x61005ff6 in _cygtls::call (func=func@entry=0x610071d0 
<dll_crt0_1(void*)>, arg=arg@entry=0x0)
     at /usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/cygtls.cc:30
#17 0x61006f54 in _dll_crt0@0 () at 
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/dcrt0.cc:1098
#18 0x00401222 in cygwin_crt0 (f=0x4011a0 <main>) at 
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/lib/cygwin_crt0.c:22
#19 0x00401015 in mainCRTStartup () at 
/usr/src/debug/cygwin-1.7.30-1/winsup/cygwin/crt0.c:29

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

