Thread safety problem (?)

Vincent Deffontaines vincent.deffontaines at
Mon Apr 18 17:51:03 CEST 2005


I use gcrypt in a multithreaded server app (namely, nufw [1]) (also uses 
glib and gnutls).

We experiment an occasionnal (hard to reproduce) crash which seems to 
always occur at the gnutls call : gnutls_handshake(). The crash is quite 
rare (and occurs in an often called loop), which leads us to believe 
this might be a thread safety problem.

Gnutls people pointed us (on this thread [2]) to the gcrypt, and told us 
we should use some locking mechanisms. Also, the "Multi-threaded 
applications" [3] webpage seems to be of interest.

Our server runs this :
static struct gcry_thread_cbs gcry_threads_gthread =
         gcry_gthread_mutex_init, gcry_gthread_mutex_destroy,
         gcry_gthread_mutex_lock, gcry_gthread_mutex_unlock

and this :

gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_gthread);

which doesn't seem to be enough to solve our problem.

As usual, the thread safety problems are very delicate, and we of course 
cannot be sure this is gcrypt's "fault" or ours, or whatever.

If anyone on this list has more ideas about what to check/add, we will 
be very interested to hear about it.

Any help/pointer will be appreciated.

Thanks for reading me,

Vincent Deffontaines


More information about the Gcrypt-devel mailing list