From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25648 invoked by alias); 1 Aug 2014 17:42:07 -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 25637 invoked by uid 89); 1 Aug 2014 17:42:06 -0000 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_NONE autolearn=ham version=3.3.2 X-HELO: vms173017pub.verizon.net Received: from vms173017pub.verizon.net (HELO vms173017pub.verizon.net) (206.46.173.17) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 01 Aug 2014 17:42:05 +0000 Received: from [192.168.1.231] ([unknown] [74.104.179.122]) by vms173017.mailsrvcs.net (Sun Java(tm) System Messaging Server 7u2-7.02 32bit (built Apr 16 2009)) with ESMTPA id <0N9N005L42HDQ790@vms173017.mailsrvcs.net> for cygwin@cygwin.com; Fri, 01 Aug 2014 12:41:47 -0500 (CDT) Message-id: <53DBD151.90308@cygwin.com> Date: Fri, 01 Aug 2014 17:42:00 -0000 From: "Larry Hall (Cygwin)" Reply-to: cygwin@cygwin.com User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-version: 1.0 To: cygwin@cygwin.com Subject: Re: Destructors not called for c++11 thread_local objects References: <53DBCF39.9050309@cs.utoronto.ca> In-reply-to: <53DBCF39.9050309@cs.utoronto.ca> Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit X-SW-Source: 2014-08/txt/msg00019.txt.bz2 On 08/01/2014 01:32 PM, Ryan Johnson wrote: > Hi all, > > (Please CC me in replies, I'm not subscribed to the list) > > Question: is this a Cygwin bug, gcc bug, or somebody else's bug entirely? > > The following STC shows the problem: > > $ cat bug.cpp > #include > static thread_local struct X { > int x; > X() { puts("hi"); } > ~X() { puts("bye!"); } > } x; > int main() { x.x = 0; } > > $ g++ -std=gnu++11 -Wall -g bug.cpp && ./a > hi > > A quick inspection of the assembly code shows no call to __cxa_thread_atexit > in __tls_init, where the same code compiled on linux, with the same version > of gcc, has it right. This is odd, because the function does seem to be > available in cygwin's libstdc++: > > $ nm /usr/lib/gcc/x86_64-pc-cygwin/4.8.3/libstdc++.a | grep thread_atexit > 0000000000000000 d .data$_ZZ19__cxa_thread_atexitE4once > 0000000000000000 p .pdata$__cxa_thread_atexit > 0000000000000000 t .text$__cxa_thread_atexit > 0000000000000000 r .xdata$__cxa_thread_atexit > 0000000000000000 T __cxa_thread_atexit > 0000000000000000 d _ZZ19__cxa_thread_atexitE4once > > Here's the linux version of __tls_init: >> __tls_init: >> .LFB19: >> cmpb $0, %fs:__tls_guard@tpoff >> je .L7 >> rep; ret >> .L7: >> subq $8, %rsp >> movl $.LC1, %edi >> movb $1, %fs:__tls_guard@tpoff >> call puts >> movq %fs:0, %rsi >> movl $__dso_handle, %edx >> movl $_ZN1XD1Ev, %edi >> addq $8, %rsp >> addq $_ZL1x@tpoff, %rsi >> jmp __cxa_thread_atexit > vs. the same for cygwin: >> __tls_init: >> subq $40, %rsp >> leaq __emutls_v.__tls_guard(%rip), %rcx >> call __emutls_get_address >> cmpb $0, (%rax) >> je .L27 >> addq $40, %rsp >> ret >> .L27: >> leaq .LC0(%rip), %rcx >> movb $1, (%rax) >> addq $40, %rsp >> jmp puts > > Relevant packages installed: > binutils 2.24.51-4 > cygwin 1.7.30-1 > gcc-core 4.8.3-2 > gcc-g++ 4.8.3-2 > libstdc++6 4.8.3-2 > > (I realize I'm a version behind on cygwin1.dll, but I don't think that's the > problem here) > > Thoughts? Well it's not a general gcc problem because the same code on Linux with version 4.8.3 works for me. -- Larry _____________________________________________________________________ A: Yes. > Q: Are you sure? >> A: Because it reverses the logical flow of conversation. >>> Q: Why is top posting annoying in email? -- 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