Are you setting up openssl to handle threading (since GCD uses threads under the covers)?
OpenSSL needs some callbacks to work correctly in the presence of threads:
http://www.openssl.org/docs/crypto/threads.html
Here's what I use (it's C++ but can be trivially translated to C):
pthread_mutex_t* mutex_buffer;
void thread_id_function(CRYPTO_THREADID* id) {
CRYPTO_THREADID_set_pointer(id, pthread_self());
}
void locking_function(int mode, int id, const char *file, int line) {
if(mode & CRYPTO_LOCK) {
pthread_mutex_lock(&mutex_buffer[id]);
} else {
pthread_mutex_unlock(&mutex_buffer[id]);
}
}
void openssl_init() {
static pthread_mutex_t* mutex_buffer;
if (!mutex_buffer) {
mutex_buffer = new pthread_mutex_t[CRYPTO_num_locks()];
for(int i=0; i<CRYPTO_num_locks(); ++i) {
pthread_mutex_init(&mutex_buffer[i], 0);
}
CRYPTO_set_locking_callback(locking_function);
CRYPTO_THREADID_set_callback(thread_id_function);
}
}
Note I use openssl for sqlcipher, libcurl, and my own code. I use all these packages from multiple queues and I'm pretty sure I can trivially show things will go south if I didn't have the callbacks set up. That said, I'm not 100% sure it's the source of your issue ...