OpenSSL :: SSL_library_init()内存泄漏 [英] OpenSSL::SSL_library_init() memory leak

查看:1973
本文介绍了OpenSSL :: SSL_library_init()内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近我开始研究C ++中的内存泄漏,所以我可能会问一个幼稚的问题。

我有一个使用OpenSSL的c ++库 - 我的任务是检查是否有内存泄漏这个lib。我已经运行Visual Leak Detector检查mem泄漏了。

我看到调用 SSL_library_init(); SSL_load_error_strings ); 是领先的泄漏 - 快速搜索显示在使用结束时,我必须调用以下:

  CONF_modules_free(); 
ERR_remove_state(0);
ENGINE_cleanup();
CONF_modules_unload(1);
ERR_free_strings();
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();

泄漏确实减少了,但仍然有两个泄漏(VLD工具显示我)因为 SSL_library_init 调用。

任何人都知道为了释放所有的mem泄漏还需要做什么?

$ b $我理解在 SSL_library_init() SSL_load_error_strings()存储在全局变量中,因此属于内存使用类别,而是在内存泄漏类别下,因为程序退出时仍可访问内存。 / p>

一个建议是,在使用SSL的每个线程中必须调用 ERR_remove_state(0),因为当您调用带有参数0的 ERR_remove_state ,它只是清除当前线程的错误状态。其他电话对我好。如果你可以发布,两个泄漏仍然由VLD显示,我可以检查。


Recently I have started studying about memory leaks in C++, so I may ask a naive questions.
I have a c++ library that is using OpenSSL - my task is to check if there are memory leaks in this lib. I have run Visual Leak Detector to check mem leaks.
I see that the calls to SSL_library_init(); and SSL_load_error_strings(); are leading leak - quick googling is showing that at the end of usage I have to call the followings:

CONF_modules_free();
ERR_remove_state(0);
ENGINE_cleanup();
CONF_modules_unload(1);
ERR_free_strings();
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();

The leak indeed decreased, but still there are two leaks(that the VLD tool shows me) that happen because the SSL_library_init call.
does anyone know what else I have to do in order to free all the mem leaks?

解决方案

As I understand all the memory which is allocated during SSL_library_init() and SSL_load_error_strings() are stored in global variables and so it comes under the category of "Memory in Use" rather under the category of Memory leak as the memory is still accessible when the program is dying out.

One suggestion is that ERR_remove_state(0) must be called in each thread where SSL is used, because when you call the ERR_remove_state with argument 0, it just clears the error state for the current thread. Other calls appears good to me. If you could post, "two leaks" which are still being displayed by VLD, I can check.

这篇关于OpenSSL :: SSL_library_init()内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆