This is the mail archive of the
mailing list for the pthreas-win32 project.
Re: Problem using PThreads TLS from a DLL.
- From: Ross Johnson <rpj at ise dot canberra dot edu dot au>
- To: Aurelio Medina <AMedina at xcaliber dot com>
- Cc: pthreads-win32 at sources dot redhat dot com, Pat Bacon <pbacon at xcaliber dot com>
- Date: Thu, 07 Feb 2002 14:06:19 +1100
- Subject: Re: Problem using PThreads TLS from a DLL.
- Organization: University of Canberra, Information Sciences and Engineering
- References: <D5C377ECA6DD12478267E89585EE642C067349@chi-mail2.win.xcaliber.com>
Aurelio Medina wrote:
> Hello all,
> I've encountered a problem when using the PThreads-Win32 (PThreadVCE)
> thread local storage (TLS) routines from within my own DLL. Before I
> dig any deeper I would like to know if anyone has seen this and/or has
> a workaround. My DLL is calloc'ing TLS data and I believe the TLS
> destructors (which I have calling free) are firing within the main app
> and not within my DLL. This causes the app that uses my DLL to crash
> in the TLS destructor when calling free. It crashes beacuse the app is
> trying to free CRT memory allocated by my DLL. Is there some PThread
> function that I can call in my DLLMain to cause the TLS destructors to
> fire when my DLL is detached?
Do I understand the problem correctly: is this because the memory is
unallocated when your DLL is unloaded and therefore free()
Are you able to join those threads before unloading
your DLL? Pthread_join() will call the destructors
for you when the threads exit.
> Aurelio Medina
| Ross Johnson | | "Come down off the cross
| Management & Technology |___| We can use the wood" - Tom Waits
| Building 11 |
| University of Canberra | eMail: firstname.lastname@example.org
| ACT 2601 | WWW:
| AUSTRALIA |