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

Martin Milata b42-ml at srck.net
Sat Dec 28 10:31:40 EST 2013


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,
Martin



More information about the OTR-dev mailing list