[MDEV-9552] client library with OpenSSL is not thread safe Created: 2016-02-12  Updated: 2022-09-08

Status: Open
Project: MariaDB Server
Component/s: SSL
Affects Version/s: 10.1.11
Fix Version/s: 5.5, 10.1

Type: Bug Priority: Minor
Reporter: Georg Richter Assignee: Georg Richter
Resolution: Unresolved Votes: 1
Labels: None

Attachments: File ssltest.c    

 Description   

Due to missing crypto mutexes client library isn't thread safe.

OpenSSL Documentation:

OpenSSL can safely be used in multi-threaded applications provided that at least two callback functions are set, locking_function and threadid_func.

locking_function(int mode, int n, const char *file, int line) is needed to perform locking on shared data structures. (Note that OpenSSL uses a number of global data structures that will be implicitly shared whenever multiple threads use OpenSSL.) Multi-threaded applications will crash at random if it is not set.

The attached test (adapted from Connector/C) crashes frequently or delivers unexpected results.

Core Dump

/lib64/libc.so.6(realloc+0x139)[0x7f870b3d1359]
/lib64/libcrypto.so.1.0.0(CRYPTO_realloc+0x50)[0x7f870b76a470]}}

Unexpected results

georg@linux-lw76:~/work/mariadb/dev/10.2-ssl/client> ./ssltest
>Error: SSL connection error: SSL_CTX_new failed
>Error: SSL connection error: SSL_CTX_new failed
>Error: SSL connection error: SSL_CTX_new failed
>Error: SSL connection error: SSL_CTX_new failed
>Error: SSL connection error: SSL_CTX_new failed
>Error: SSL connection error: SSL_CTX_new failed
>Error: SSL connection error: SSL_CTX_set_default_verify_paths failed
>Error: SSL connection error: SSL_CTX_set_default_verify_paths failed
Found: 42
Expected 50


Generated at Thu Feb 08 07:35:31 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.