apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Justin Erenkrantz" <jus...@erenkrantz.com>
Subject Re: svn commit: r434327 - in /apr/apr/trunk: CHANGES include/arch/win32/apr_arch_threadproc.h misc/win32/start.c threadproc/win32/threadpriv.c
Date Sun, 29 Oct 2006 05:56:15 GMT
On 10/10/06, William A. Rowe, Jr. <wrowe@rowe-clan.net> wrote:
> Thanks Branko - and Mladen - I'm studying the code, Mladen's interpretation
> for threadpriv.c and compilation on vc 6.0, 2002, 2003 and 2005 flavor VS's
> to determine if this is the best solution, and should be ready to comment
> more tomorrow.
> I'm especially interested in the emits Mladen later reported which I'll work
> on diagnosing and explaining.  It might take a bit of reverse engineering.

I don't really know the root cause, but this whole set of changes
borks Subversion when it tries to terminate with VS 2005.

As best as I can determine, the calling sequence is:

1) svn.exe's main() function exits normally
2) apr_terminate() gets invoked
3) threadkey_terminate() is called
4) APR's DllMain() is called with DLL_THREAD_DETACH
5) threadkey_detach() is called
6) apr_hash_first() is called with an invalid pointer

threadkey_detach() segfaults because it tries to access memory that
was freed in apr_terminate().

I've managed to resolve this locally by the patch below.  Does this
make sense?  -- justin

Index: misc/win32/start.c
--- misc/win32/start.c  (revision 464264)
+++ misc/win32/start.c  (working copy)
@@ -253,7 +253,9 @@
         case DLL_THREAD_ATTACH:
         case DLL_THREAD_DETACH:
-            threadkey_detach();
+            if (initialized) {
+                threadkey_detach();
+            }
         case DLL_PROCESS_DETACH:

View raw message