| www.delorie.com/archives/browse.cgi | search |
| 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 | |
| :content-type:content-transfer-encoding; q=dns; s=default; b=G55 | |
| 6+n052Y/Gj+i4ms321MvojJtD+68DamMZpQLtnsoxflWZFCktn+GaXLH4ZCtR24B | |
| r7tykefERpLeyVT0c9z1f3YGTDK3Ue1bLoNd1Ar0cBFhq91KXwDi9SuKvxsXMTnQ | |
| 2HGUUg56mgy50ehPjJUKUICZTZJ8Bn0D0qFBZ0YI= | |
| 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=MwSIvXb/q | |
| zysWZ8hTG+FB7CM5po=; b=BXeO+sbTe3jRihjXYd63O1TaMMAj9DhtC9MeTnu0c | |
| MfHkHPcrh8ato60PpKwEuX2PiViv6uhwICjFdEnC84tA3Nf4fgYDBJAU+L/06foM | |
| EA0a8W20R2CWzfJd7UO7VkA9eSg5DwOlbWvOe+hBlCMwqXmerjiIc7SjqIID4kaB | |
| yA= | |
| 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=-2.2 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,RP_MATCHES_RCVD,SPF_NEUTRAL autolearn=ham version=3.3.2 |
| X-HELO: | bureau92.ns.utoronto.ca |
| Message-ID: | <53DBCF39.9050309@cs.utoronto.ca> |
| Date: | Fri, 01 Aug 2014 13:32:41 -0400 |
| From: | Ryan Johnson <ryan DOT johnson AT cs DOT utoronto DOT ca> |
| User-Agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 |
| MIME-Version: | 1.0 |
| To: | "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com> |
| Subject: | Destructors not called for c++11 thread_local objects |
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 <cstdio>
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 AT tpoff
> je .L7
> rep; ret
> .L7:
> subq $8, %rsp
> movl $.LC1, %edi
> movb $1, %fs:__tls_guard AT tpoff
> call puts
> movq %fs:0, %rsi
> movl $__dso_handle, %edx
> movl $_ZN1XD1Ev, %edi
> addq $8, %rsp
> addq $_ZL1x AT 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?
Ryan
--
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
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |