Attached is a patch that fixes the problem.

The OpenSSL thread locking code added in 2.7.1, which OpenSSL requires in order to be thread-safe, contained a bug which leaked a small amount of memory (one "int" per thread) on all operating systems, and had the added bonus of provoking an infinite loop upon thread exit on Solaris because of an idiosyncracy in Sun's implementation of pthreads.

The patch I sent out privately as a trial earlier today fixes the loop, but not the leak.

The actual patch here is only two lines of additional code, but it's wrapped it in descriptive text which is why the patch is somewhat larger than that.

I'll probably release a v2.7.2 in about a week which contains this fix.

If you're not having any problems with 2.7.0, feel free to downgrade to it or remain there until the 2.7.2 announcement. On the other hand, if you were having problems with 2.7.0, the upgrade to 2.7.1 plus this patch is the way to go for now.
Index: dkim-crypto.c
===================================================================
RCS file: /cvs/dkim-filter/dkim-crypto.c,v
retrieving revision 1.2
retrieving revision 1.4
diff -u -r1.2 -r1.4
--- dkim-crypto.c       28 Aug 2008 06:41:31 -0000      1.2
+++ dkim-crypto.c       28 Aug 2008 21:51:31 -0000      1.4
@@ -2,11 +2,11 @@
 **  Copyright (c) 2008 Sendmail, Inc. and its suppliers.
 **     All rights reserved.
 **
-**  $Id: dkim-crypto.c,v 1.2 2008/08/28 06:41:31 msk Exp $
+**  $Id: dkim-crypto.c,v 1.4 2008/08/28 21:51:31 msk Exp $
 */
 
 #ifndef lint
-static char dkim_crypto_c_id[] = "@(#)$Id: dkim-crypto.c,v 1.2 2008/08/28 
06:41:31 msk Exp $";
+static char dkim_crypto_c_id[] = "@(#)$Id: dkim-crypto.c,v 1.4 2008/08/28 
21:51:31 msk Exp $";
 #endif /* !lint */
 
 /* system includes */
@@ -100,9 +100,27 @@
 static void
 dkimf_crypto_free_id(void *ptr)
 {
+       /*
+       **  Trick dkim_crypto_get_id(); the thread-specific pointer has already
+       **  been cleared at this point, but dkimf_crypto_get_id() will be
+       **  called by libcrypto which will in then allocate a new thread
+       **  pointer if the thread-specific pointer isn't set.  This means
+       **  a memory leak of thread IDs and, on Solaris, an infinite loop
+       **  because the destructor (indirectly) re-sets the thread-specific
+       **  pointer to something not NULL.  See pthread_key_create(3).
+       */
+
+       assert(pthread_setspecific(id_key, ptr) == 0);
+
        ERR_remove_state(0);
        if (ptr != NULL)
                free(ptr);
+
+       /*
+       **  Now we can actually clear it for real.
+       */
+
+       assert(pthread_setspecific(id_key, NULL) == 0);
 }
 
 /*
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
dkim-milter-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dkim-milter-discuss

Reply via email to