I have an application that has to calculate the MD5 of file, I have used the openssl library, valgrind complains about some blocks still reachable.
Compile the following code:
#include <openssl/bio.h>
int main(int, char**)
{
BIO * mem = BIO_new(BIO_s_mem());
BIO_vfree(mem);
return 0;
}
the run it using valgrind this is what I'm obtaining:
==23597== 220 bytes in 6 blocks are still reachable in loss record 1 of 1
==23597== at 0x4022D78: malloc (vg_replace_malloc.c:207)
==23597== by 0x432FD0D: (within /usr/lib/i686/cmov/libcrypto.so.0.9.8)
==23597== by 0x433036E: CRYPTO_malloc (in /usr/lib/i686/cmov/libcrypto.so.0.9.8)
==23597== by 0x43989C9: lh_new (in /usr/lib/i686/cmov/libcrypto.so.0.9.8)
==23597== by 0x4332025: (within /usr/lib/i686/cmov/libcrypto.so.0.9.8)
==23597== by 0x433249B: (within /usr/lib/i686/cmov/libcrypto.so.0.9.8)
==23597== by 0x4332B5D: CRYPTO_new_ex_data (in /usr/lib/i686/cmov/libcrypto.so.0.9.8)
==23597== by 0x438E053: BIO_set (in /usr/lib/i686/cmov/libcrypto.so.0.9.8)
==23597== by 0x438E0E9: BIO_new (in /usr/lib/i686/cmov/libcrypto.so.0.9.8)
==23597== by 0x80485E1: main (in /home/kalman/cxx_test/md5test/a.out)
anyone had same experience ?
OpenSSL has actions that confuse Valgrind when not compiled with -DPURIFY. Is this the error you are seeing?
I believe those are some static structures that openssl allocates. I ran your code, and I ran the following code and valgrind reported that both had the same amount of unfreed memory:
#include <openssl/bio.h>
int main(int, char**)
{
BIO * mem = BIO_new(BIO_s_mem());
BIO * mem2 = BIO_new(BIO_s_mem());
BIO * mem3 = BIO_new(BIO_s_mem());
BIO * mem4 = BIO_new(BIO_s_mem());
BIO_vfree(mem);
BIO_vfree(mem2);
BIO_vfree(mem3);
BIO_vfree(mem4);
return 0;
}
~
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With