[OTR-dev] libotr: crash when generating privkey in another thread

David Goulet dgoulet at ev0ke.net
Sat Dec 28 10:38:34 EST 2013


On 28 Dec (16:31:40), Martin Milata wrote:
> On Mon, Dec 16, 2013 at 21:26:11 -0500, David Goulet wrote:
> > On 16 Dec (21:19:31), Ian Goldberg wrote:
> > > On Tue, Dec 17, 2013 at 01:36:52AM +0100, Martin Milata wrote:
> > > > Hi!
> > > > 
> > > > I'm writing a program that uses libotr-4.0.0 and encountered a problem
> > > > when trying to perform key generation in backtround thread.
> > > > 
> > > > When the key generation is running and another OTR query is received by
> > > > libotr the program crashes with following stacktrace:
> > > > 
> > > > ath.c:193: _gcry_ath_mutex_lock: Assertion `*lock == ((ath_mutex_t) 0)' failed.
> > > 
> > > What's supposed to happen is when you try to generate the key for the
> > > same account the second time, otrl_privkey_generate_start will return
> > > gcry_error(GPG_ERR_EEXIST), and *newkeyp is set to NULL.  Are you
> > > checking for this?  The second OTR query should not cause a launch of a
> > > background thread at all.
> > > 
> > > Or do you mean you received OTR Query messages for two _different_ local
> > > accounts?
> > > 
> > > 
> > > But more generally, libotr has no way of knowing what threading library
> > > your application is using, so your application may well need to call the
> > > gcry_control to enable multithreading.  Does the problem go away if you
> > > do that before calling OTRL_INIT?
> > 
> > FYI, for the irssi OTR plugin, I had to do that just before OTRL_INIT
> > for libgcrypt to use pthread.
> > 
> > 	gcry_control (GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
> 
> Yes, that helps. The irssi plugin seems to be well-written, I found
> myself looking at the source code for hints several times already;)

Thanks! To be fair, I did the same thing with pidgin-otr, LOTS of code
reading in that code base. :)

Don't hesitate to report bug or issues if you find some :).

Cheers!
David

> 
> Thanks,
> Martin
> _______________________________________________
> OTR-dev mailing list
> OTR-dev at lists.cypherpunks.ca
> http://lists.cypherpunks.ca/mailman/listinfo/otr-dev
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: Digital signature
URL: <http://lists.cypherpunks.ca/pipermail/otr-dev/attachments/20131228/6738f9fd/attachment.pgp>


More information about the OTR-dev mailing list