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

Martin Milata b42-ml at srck.net
Mon Dec 16 19:36:52 EST 2013


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.

Keygen thread:
#0  poll
#1  _gcry_rndlinux_gather_random
#2  read_random_source
#3  _gcry_rngcsprng_randomize
#4  _gcry_random_bytes_secure
#5  dsa_generate_ext
#6  _gcry_pk_genkey
#7  otrl_privkey_generate_calculate
#8  COtrMod::GenKeyThreadFunc
#9  start_thread
#10 clone

Main thread:
#0  raise
#1  abort
#2  __assert_fail_base
#3  __assert_fail
#4  _gcry_ath_mutex_lock
#5  lock_pool
#6  initialize
#7  _gcry_rngcsprng_randomize
#8  _gcry_random_bytes_secure
#9  otrl_dh_gen_keypair
#10 otrl_auth_start_v23
#11 otrl_message_receiving
#12 COtrMod::OnPrivMsg
#...continues

Is this a bug or am I doing something wrong? Libgcrypt manual says [1]
that there has to be some kind of initialization before multi-thread
use. It doesn't seem to be done in libotr, is the user of the library
supposed to do that?

I'm using libotr-4.0.0 and libgcrypt-1.5.3 on Fedora 19.

Thanks,
Martin

[1]: http://www.gnupg.org/documentation/manuals/gcrypt/Multi_002dThreading.html
-------------- next part --------------
(gdb) thread apply all bt

Thread 3 (Thread 0x7f329bc24700 (LWP 1730)):
#0  0x00007f329e1d17fd in poll () from /lib64/libc.so.6
#1  0x00007f329c677ea8 in _gcry_rndlinux_gather_random () from /lib64/libgcrypt.so.11
#2  0x00007f329c6753b0 in read_random_source () from /lib64/libgcrypt.so.11
#3  0x00007f329c6764c2 in _gcry_rngcsprng_randomize () from /lib64/libgcrypt.so.11
#4  0x00007f329c675190 in _gcry_random_bytes_secure () from /lib64/libgcrypt.so.11
#5  0x00007f329c667f34 in dsa_generate_ext () from /lib64/libgcrypt.so.11
#6  0x00007f329c6413c4 in _gcry_pk_genkey () from /lib64/libgcrypt.so.11
#7  0x00007f329c8ae47f in otrl_privkey_generate_calculate (newkey=0x7f32a0902d50) at privkey.c:516
#8  0x00007f329cac6e43 in COtrMod::GenKeyThreadFunc (data=0x7f32a08ff650) at otr.cpp:279
#9  0x00007f329e4aec53 in start_thread () from /lib64/libpthread.so.0
#10 0x00007f329e1dbdbd in clone () from /lib64/libc.so.6

Thread 2 (Thread 0x7f329c425700 (LWP 1722)):
#0  0x00007f329e4b2565 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0
#1  0x00007f329fc8b471 in CThreadPool::threadFunc() ()
#2  0x00007f329fc8bd39 in CThreadPool::threadPoolFunc(void*) ()
#3  0x00007f329e4aec53 in start_thread () from /lib64/libpthread.so.0
#4  0x00007f329e1dbdbd in clone () from /lib64/libc.so.6

Thread 1 (Thread 0x7f329fb44840 (LWP 1721)):
#0  0x00007f329e11b9e9 in raise () from /lib64/libc.so.6
#1  0x00007f329e11d0f8 in abort () from /lib64/libc.so.6
#2  0x00007f329e114956 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007f329e114a02 in __assert_fail () from /lib64/libc.so.6
#4  0x00007f329c63b69d in _gcry_ath_mutex_lock () from /lib64/libgcrypt.so.11
#5  0x00007f329c675820 in lock_pool () from /lib64/libgcrypt.so.11
#6  0x00007f329c67591e in initialize () from /lib64/libgcrypt.so.11
#7  0x00007f329c676180 in _gcry_rngcsprng_randomize () from /lib64/libgcrypt.so.11
#8  0x00007f329c675190 in _gcry_random_bytes_secure () from /lib64/libgcrypt.so.11
#9  0x00007f329c8b2db2 in otrl_dh_gen_keypair (groupid=groupid at entry=5, kp=kp at entry=0x7f32a0902120) at dh.c:108
#10 0x00007f329c8b7c0d in otrl_auth_start_v23 (auth=0x7f32a0902110, version=2) at auth.c:158
#11 0x00007f329c8b61e4 in otrl_message_receiving (us=0x7f32a08fc920, ops=0x7f329ccd2280 <COtrMod::m_xOtrOps>, 
    opdata=0x7f32a08ff650, accountname=<optimized out>, protocol=<optimized out>, sender=0x7f32a09033d8 "xchat", 
    message=0x7f32a0905df8 "?OTR?v2? <b>xchat at irc.the.net</b> has requested an <a href=\"http://otr.cypherpunks.ca/\">Off-the-Record private conversation</a>.  However, you do not have a plugin to support that. See <a href=\"http:/"..., 
    newmessagep=0x7fff5c7dc438, tlvsp=0x0, contextp=0x0, add_appdata=0x0, data=0x0) at message.c:1152
#12 0x00007f329cac928e in COtrMod::OnPrivMsg (this=0x7f32a08ff650, Nick=..., sMessage=...) at otr.cpp:240
#13 0x00007f329fc19672 in CModules::OnPrivMsg(CNick&, CString&) ()
#14 0x00007f329fbe15a7 in CIRCSock::OnPrivMsg(CNick&, CString&) ()
#15 0x00007f329fbf1fff in CIRCSock::ReadLine(CString const&) ()
#16 0x00007f329fba3923 in Csock::PushBuff(char const*, unsigned long, bool) ()
#17 0x00007f329fbad13e in CSocketManager::Loop() ()
#18 0x00007f329fbaaf43 in CSocketManager::DynamicSelectLoop(unsigned long, unsigned long, long) ()
#19 0x00007f329fbc5109 in CZNC::Loop() ()
#20 0x00007f329fb92dd9 in main ()


More information about the OTR-dev mailing list