From: Klaus Fischer <klaus.fischer@tara-systems.de>
To: pthreads-win32@sourceware.org
Subject: Crash when re-initializing as static library
Date: Wed, 06 Nov 2013 17:53:00 -0000 [thread overview]
Message-ID: <527A8215.4010309@tara-systems.de> (raw)
Dear pthreads-win32 developers,
I have experienced a crash when building pthreads-win32 as static
library and re-initializing it using the following sequence:
- pthread_win32_process_attach_np()
- pthread_win32_process_detach_np()
- pthread_win32_process_attach_np()
The global variable ptw32_threadReuseTop still points to memory used
between the first attach/detach run, but this memory was already freed
in function ptw32_processTerminate(), which was called during detaching.
When using e.g. pthread_self() afterwards, the global
ptw32_threadReuseTop now points to invalid memory, causing an access
violation writing to that memory location.
A simple code change fixed that problem by assigning the default value
PTW32_THREAD_REUSE_EMPTY to that global variable at the end of function
ptw32_processTerminate(), after the while loop freeing all still
allocated thread handles.
A better way to fix that would probably be to initialize all the library
globals of global.c during the attaching stage. In a static library,
those globals are only initialized once when the process starts, but
_should_ be re-initialized on every attach.
I know this is not a concern when using this library as dynamic library,
but since there is an option to use it as static library and other
people also use it that way according to the mailing list, it would be
great if it could survive multiple re-initializations.
Thanks in advance,
Klaus
--
_________________________________________________________
Dipl. Inf. Klaus FISCHER - Software Engineer
mailto: klaus.fischer@tara-systems.de
_________________________________________________________
next reply other threads:[~2013-11-06 17:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-06 17:53 Klaus Fischer [this message]
2013-11-06 23:17 ` Ross Johnson
2013-11-07 14:19 Klaus Fischer
2013-11-07 23:47 ` Ross Johnson
2013-11-08 10:39 ` Klaus Fischer
2013-11-14 13:34 ` Klaus Fischer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=527A8215.4010309@tara-systems.de \
--to=klaus.fischer@tara-systems.de \
--cc=pthreads-win32@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).