Hi, When working on NuFW (http://www.nufw.org), I've encounter some weird crash when calling sasl_dispose. The problem was in fact a logic problem in sasl_set_mutex. NuFW uses sasl and libldap_r. NuFW has to do a call to sasl_set_mutex because it is multithreaded. One of the NuFW module uses libldap_r which also does a call to sasl_set_mutex. By doing this, we run into a problem because sasl_MUTEX_* function change during run time. Thus we can allocate a mutex with NuFW function and destroy it with libldap_r function. This lead to a crash in almost all cases. IMHO, the only clean workaround is to modify sasl_set_mutex(): it should not be run twice in the same program. I attach a simple patch to this mail which implement this behaviour. BR, -- Eric Leblond INL: http://www.inl.fr/ NuFW: http://www.nufw.org/
Index: lib/common.c =================================================================== RCS file: /cvs/src/sasl/lib/common.c,v retrieving revision 1.116 diff -r1.116 common.c 154a155,161 > /* only one call is permitted, if one of the function has already > * been changed we are in trouble in a subsequent call */ > if ((_sasl_mutex_utils.alloc != &sasl_mutex_alloc) || > (_sasl_mutex_utils.lock != &sasl_mutex_lock) || > (_sasl_mutex_utils.unlock != &sasl_mutex_unlock) || > (_sasl_mutex_utils.free != &sasl_mutex_free)) > return;
Attachment:
signature.asc
Description: Digital signature