openssl / valgrind
我有一个必须计算文件 MD5 的应用程序,我有 使用了 openssl 库,valgrind 仍然抱怨一些块 可达。
编译以下代码:
#include <openssl/bio.h>
int main(int, char**)
{
BIO * mem = BIO_new(BIO_s_mem());
BIO_vfree(mem);
return 0;
}
使用 valgrind 运行它,这就是我得到的:
==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)
有人有相同的经历吗?
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 ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当未使用 -DPURIFY 编译时,OpenSSL 的某些操作会使 Valgrind 感到困惑。 这是您看到的错误吗?
OpenSSL has actions that confuse Valgrind when not compiled with -DPURIFY. Is this the error you are seeing?
我相信这些是 openssl 分配的一些静态结构。 我运行了你的代码,并运行了以下代码,valgrind 报告两者都有相同数量的未释放内存:
~
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:
~
int_new_ex_data() 不会释放 def_get_class malloc 的内存。
请参阅:http://openssl.6102.n7 .nabble.com/memory-leak-in-engine-cleanup-td30935.html
http://rt.openssl.org/Ticket /Display.html?id=2673&user=guest&pass=guest
int_new_ex_data() do not release the mem that def_get_class malloced.
SEE: http://openssl.6102.n7.nabble.com/memory-leak-in-engine-cleanup-td30935.html
http://rt.openssl.org/Ticket/Display.html?id=2673&user=guest&pass=guest
OpenSSL 包含大量未初始化的变量、从未释放的变量和内存、从未清除的变量以及无法在范围外访问甚至无法手动释放的变量。
Valgrind 发现了很多这样的东西。
PURIFY 标志仅与 rand()_function 相关。 因此,为了避免 Purify 中的检测,如果设置了该标志,Openssl 实际上会使用不同的源代码。 很好的编码...也许最好首先解决问题?!
OpenSSL contains a lot of uninitialized variables, variables and memory never freed, variables never cleared and not reachable outside scope to even be freed manually.
Valgrind finds a lot of these.
The PURIFY flag is only related to the rand()_function. So to avoid a detection in Purify Openssl actually uses different source code if that flag is set. Nice coding... Maybe better to fix the problem in first place?!