Bug 629673 - libpthread: thread-specific data destructor is never invoked
Summary: libpthread: thread-specific data destructor is never invoked
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: glibc
Version: 13
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
Assignee: Andreas Schwab
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-09-02 16:59 UTC by Bart Van Assche
Modified: 2016-11-24 16:07 UTC (History)
5 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2010-09-29 12:34:42 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
Test program. (539 bytes, text/x-c++src)
2010-09-02 16:59 UTC, Bart Van Assche
no flags Details

Description Bart Van Assche 2010-09-02 16:59:05 UTC
Created attachment 442676 [details]
Test program.

Description of problem:
The POSIX threads function pthread_key_create() allows to specify a destructor function as the second argument. Apparently that destructor function is never invoked.


Version-Release number of selected component (if applicable):
$ head -n 1 /etc/issue.net 
Fedora release 13 (Goddard)
$ rpm -qf /lib64/libpthread.so.0
glibc-2.12-3.x86_64


How reproducible:
100%


Steps to Reproduce:
1. Build pthread_once.cpp
2. Run ./pthread_once

  
Actual results:
key = 0x0x1313010
Done.


Expected results:
key = 0x0x1313010
destructor(): arg = 0x0x1313010
Done.

Comment 1 Bart Van Assche 2010-09-02 18:16:13 UTC
Notes:
- I have not yet found any clause in IEEE Std 1003.1 that specifies whether or not thread-local destructors must be invoked when the main thread exits.
- I have not yet been able to find any clause in the same document that specifies whether or not it is allowed to call pthread_exit() from main().
See also http://www.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_09.

Comment 2 Denis Arnaud 2010-09-02 18:31:07 UTC
I've tested your (attached) program on Debian (Squeeze/Sid), and the result is the same as on Fedora.

Comment 3 Bart Van Assche 2010-09-02 18:38:26 UTC
(In reply to comment #2)
> I've tested your (attached) program on Debian (Squeeze/Sid), and the result is
> the same as on Fedora.

I assume that's because Debian and Fedora compile glibc from the same source code. It would be great if someone could find out what the POSIX spec says about what the behavior really should be.

Comment 4 Andreas Schwab 2010-09-29 12:34:42 UTC
<http://opengroup.org/onlinepubs/9699919799/functions/_Exit.html#tag_16_01_03_01>:

Threads terminated by a call to _Exit() or _exit() shall not invoke their cancellation cleanup handlers or per-thread data destructors.


Note You need to log in before you can comment on or make changes to this bug.