Hello, I'm working on a client - multithreaded-server application, both side authenticating each other with auto-signed certs.
After lots of adventures, I finally end-up with a memory leak problem which is detected using valgrind (and crazy self-test with tons of clients connecting to the server). When the server is asked to leave, then valgrind complains about unallocated memory (allocated in server's threads, one per connection from clients): c_ssl = SSL_new(c_ctx); c_ssl_client = BIO_new_socket(c_peer_sock, BIO_NOCLOSE); SSL_set_bio(c_ssl, c_ssl_client, c_ssl_client); c_buf_io = BIO_new(BIO_f_buffer()); /* create a buffer BIO */ --> c_ssl_bio = BIO_new(BIO_f_ssl()); /* create an ssl BIO */ BIO_set_ssl(c_ssl_bio, c_ssl, BIO_CLOSE); /* assign the ssl BIO to SSL */ BIO_push(c_buf_io, c_ssl_bio); /* add c_ssl_bio to c_buf_io */ This BIO_new(BIO_f_ssl()) is leaking and apparently I do not know how to release it. What I do when a server's thread has finished working is: if (c_buf_io) BIO_free(c_buf_io); if (c_ssl_client) BIO_free_all(c_ssl_client); if (c_ssl) SSL_free(c_ssl); // memory leak !! (this BIO_free() segfaults) //if (c_ssl_bio) // BIO_free(c_ssl_bio); // from http://readlist.com/lists/openssl.org/openssl-users/0/1352.html // (no effect) ERR_remove_state(0); ERR_free_strings(); // might be useless Surely I'm doing something wrong, and I'd be glad if some experts from you could lighten me :-) Best regards, David Gauchard Valgrind logs : ==5410== 1,597,904 (699,608 direct, 898,296 indirect) bytes in 10,931 blocks are definitely lost in loss record 15 of 15 ==5410== at 0x401D38B: malloc (vg_replace_malloc.c:149) ==5410== by 0x430556D: default_malloc_ex (mem.c:79) ==5410== by 0x4305BD8: CRYPTO_malloc (mem.c:304) ==5410== by 0x4364225: BIO_new (bio_lib.c:70) ==5410== by 0x8055B4E: (c_ssl_bio = BIO_new(BIO_f_ssl());) ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]