Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenSSL memory leak without call to SSL_COMP_free_compression_methods #817

Closed
jveazey opened this issue May 18, 2016 · 11 comments
Closed

OpenSSL memory leak without call to SSL_COMP_free_compression_methods #817

jveazey opened this issue May 18, 2016 · 11 comments

Comments

@jveazey
Copy link

@jveazey jveazey commented May 18, 2016

I did this

`

/* Memory leak detecting */
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#define WIN32_LEAN_AND_MEAN 
#include <Windows.h>
#include <tchar.h>
#ifndef CURL_STATICLIB
#define CURL_STATICLIB
#endif
#include <curl/curl.h>
#pragma comment(lib, "libcurl_a.lib")

int _tmain(int argc, _TCHAR* argv[])
{
    _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR );
    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR );
    _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_DEBUG | _CRTDBG_MODE_FILE);
    _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR );
    _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );

    CURLcode output = curl_global_init(CURL_GLOBAL_ALL);
    curl_global_cleanup();

    _CrtDumpMemoryLeaks( );

    return 0;
}

`

It displayed the following

`

Detected memory leaks!
Dumping objects ->
{2966} normal block at 0x02499DF8, 16 bytes long.
 Data: <                > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
{2965} normal block at 0x024988F0, 20 bytes long.
 Data: <      I         > 00 00 00 00 F8 9D 49 02 01 00 00 00 04 00 00 00 
Object dump complete.

`

Possible fix

Calling SSL_COMP_free_compression_methods(); after curl_global_cleanup(); appears to fix the problem.

See also #2561: Memory leak with SSL built-in compressions

curl/libcurl version

curl 7.48.0 (i386-pc-win32) libcurl/7.48.0 OpenSSL/1.0.2h zlib/1.2.8 WinIDN
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile SSPI Kerberos SPNEGO NTLM SSL libz

operating system

Windows 10

@bagder
Copy link
Member

@bagder bagder commented May 19, 2016

So when built and used normally there is no leak.

You rebuild OpenSSL and run it again and now it leaks. Isn't that an OpenSSL problem? Isn't that an ABI break that it doesn't behave the same way?

@jveazey
Copy link
Author

@jveazey jveazey commented May 19, 2016

By default, OPENSSL_NO_COMP is not defined. At least, when using nt.mak and ntdll.mak

Edit: The only thing I've changed in the default VC++ build process is the runtime library

@bagder
Copy link
Member

@bagder bagder commented May 19, 2016

Oh, are you saying you have a memory leak with a default build of OpenSSL? I don't, on Linux at least.

@jveazey
Copy link
Author

@jveazey jveazey commented May 19, 2016

That's correct. Sorry for the confusion. I included OPENSSL_NO_COMP in the title because is directly related to the problem. Sensibly, it should be defined in the default build process, but I avoid modifying that build process as much as possible.

To give you some details on what is happening. I am wrapping cURL in a COM library (staticly linked to cURL and OpenSSL) that can be loaded/unloaded as needed. I'm not entirely sure how COM isolates the memory, but I know that every time the library loads it allocates new memory within the process. That's why we can't just load curl_global_init(CURL_GLOBAL_ALL) at the beginning of the process. It can't reference the "shared" memory from its previous loading.

Anyway, during a stress test, I found that the library was leaking an 36 bytes every time it was loaded/unloaded which added up after a few hours. That lead to the code sample in the original post.

@jay
Copy link
Member

@jay jay commented May 20, 2016

Confirmed with Windows 7 x64 Enterprise w/curl from master (53ae370 2016-05-20) and OpenSSL/1.0.2h default config. I guess it is documented somewhere in openssl that we're supposed to call that function on cleanup? This is the first time I've heard of it.

curl 7.49.0-DEV (i386-pc-win32) libcurl/7.49.0-DEV OpenSSL/1.0.2h
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS Debug Largefile NTLM SSL

I am wrapping cURL in a COM library (staticly linked to cURL and OpenSSL) that can be loaded/unloaded as needed. I'm not entirely sure how COM isolates the memory, but I know that every time the library loads it allocates new memory within the process. That's why we can't just load curl_global_init(CURL_GLOBAL_ALL) at the beginning of the process. It can't reference the "shared" memory from its previous loading.

Initializing libcurl from a DLL is tricky. curl_global_init and curl_global_cleanup are not thread safe and may call the initialization and cleanup routines of other libraries that are not thread safe. It's documented to not call init when any other threads are running. Also read this tldr. Also you must follow thread safety requirements.

@bagder
Copy link
Member

@bagder bagder commented May 20, 2016

It's a horrible mess.

The SSL_COMP_free_compression_methods function was added in OpenSSL in 2014: openssl/openssl@db7b5e0 (unknown to me just now which versions that have it)

Docs added over a year later in 2015: openssl/openssl@c490a55

In April 2016, the function is marked deprecated and a no-op: openssl/openssl@03b0e73 (I assume this is the 1.1.0 branch)

So, there's a version gap in there during which it can/should be used...

@jveazey
Copy link
Author

@jveazey jveazey commented May 20, 2016

Initializing libcurl from a DLL is tricky.

I'm still doing testing on it and it won't be something that I'll push into production lightly. The whole reason this came up is that OpenSSL is already loaded in memory. The library wasn't able to reference that shared memory. cURL always reported SSL errors. I switched to using CURL_GLOBAL_ALL and it resolved the problem. The other parts of the code that use OpenSSL - even after the library has been loaded/unloaded thousands of times - appear to be unaffected (so far).

It's a horrible mess.

Agreed. Plus, the updated documentation for 1.1.0 states that everything will be handled automagically, but given my predicament, I'll have to force cleanup one way or another.

As of version 1.1.0 OpenSSL will automatically allocate all resources that it needs so no explicit initialisation is required. Similarly it will also automatically deinitialise as required.

https://www.openssl.org/docs/manmaster/ssl/OPENSSL_init_ssl.html
https://www.openssl.org/docs/manmaster/crypto/OPENSSL_init_crypto.html

Given the state of things, you should probably change this to a "will not fix". I just want there to be a clear record of it, one way or another.

@bagder bagder changed the title Memory leak when OpenSSL is compiled without OPENSSL_NO_COMP defined OpenSSL memory leak without call to SSL_COMP_free_compression_methods May 20, 2016
jay added a commit that referenced this issue May 20, 2016
- Free compression methods if OpenSSL 1.0.2 to avoid a memory leak.

Bug: #817
Reported-by: jveazey@users.noreply.github.com
@jay
Copy link
Member

@jay jay commented May 20, 2016

I'm still doing testing on it and it won't be something that I'll push into production lightly. The whole reason this came up is that OpenSSL is already loaded in memory. The library wasn't able to reference that shared memory. cURL always reported SSL errors. I switched to using CURL_GLOBAL_ALL and it resolved the problem. The other parts of the code that use OpenSSL - even after the library has been loaded/unloaded thousands of times - appear to be unaffected (so far).

If you have a static OpenSSL library in your DLL you should be OK as long as you control the code and know what is going on. The problems come in when there are OpenSSL DLLs (or shared objects in the case of Linux) that are used by the application or another library loaded by the application (ie not your library) and do their own openssl initialization or thread hook routines (usurping yours). In some cases if it's proven that it's guaranteed to be already initialized properly by other means I've advised to not call with global_all (in other words do CURL_GLOBAL_ALL & ~CURL_GLOBAL_SSL), because you don't want to init SSL and set it up if it's already initialized and working and must continue after you call curl_global_cleanup.
Now that said in your case because you have static OpenSSL that is available in your DLL that static OpenSSL can't be used by other parts of your program (except through some function publicly exposed in your DLL of course). So you must initialize your static openssl and deinit. Also side note, I think there were some problems on windows with static openssl if you use the static crt, and they recommended at one point dynamic crt only (ie dll), not sure if that still applies.
Another thing, a bit more advanced - if you didn't want static openssl and instead wanted the openssl dlls because they are easier to update when modular, and wanted to avoid such conflicts, you could change the name of the DLLs like ssleay32_for_mylib.dll for build or modify the .lib to change the name of the dll (I don't remember how to do this but it's possible) then put that changed name in the .lib so that the lib links to that DLL name when your DLL searches for the __imp functions. In other words your DLL can have its own OpenSSL DLLs. In 1.1.0 from what I've read I don't think any of that would be necessary as long as it's built with threading support.

Given the state of things, you should probably change this to a "will not fix". I just want there to be a clear record of it, one way or another.

We support and will continue to support 1.0.2 so I've put in a fix. Thanks, landed in 3caaeff.

@jay jay closed this May 20, 2016
@arekm
Copy link

@arekm arekm commented Jul 6, 2016

This change is causing segfault of php when curl module is loaded. Reverting commit 3caaeff and problem is gone.

Tested on php5.3.29 and 5.5.36. openssl 1.0.2h

 php -r ''
*** Error in `php': double free or corruption (out): 0x00000000010927a0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x701e6)[0x7f95e25c11e6]
/lib64/libc.so.6(+0x759f6)[0x7f95e25c69f6]
/lib64/libc.so.6(+0x761de)[0x7f95e25c71de]
/lib64/libcrypto.so.1.0.0(CRYPTO_free+0x1d)[0x7f95defed4cd]
/lib64/libcrypto.so.1.0.0(sk_pop_free+0x33)[0x7f95df0a73a3]
/usr/lib64/libcurl.so.4(+0x5fbc9)[0x7f95e0a09bc9]
/usr/lib64/libcurl.so.4(curl_global_cleanup+0x55)[0x7f95e09db965]
/usr/lib64/php55/curl.so(zm_shutdown_curl+0x8)[0x7f95e0c2ee18]
/usr/lib64/libphp_common-5.5.36.so(module_destructor+0x47)[0x7f95e4aa9227]
/usr/lib64/libphp_common-5.5.36.so(+0x1e9815)[0x7f95e4aae815]
/usr/lib64/libphp_common-5.5.36.so(zend_hash_graceful_reverse_destroy+0x18)[0x7f95e4ab00e8]
/usr/lib64/libphp_common-5.5.36.so(zend_shutdown+0x7f)[0x7f95e4aa165f]
/usr/lib64/libphp_common-5.5.36.so(php_module_shutdown+0x2b)[0x7f95e4a4062b]
php(main+0x3eb)[0x404dcb]
/lib64/libc.so.6(__libc_start_main+0xf0)[0x7f95e25717a0]
php(_start+0x29)[0x404f99]
======= Memory map: ========
00400000-00413000 r-xp 00000000 08:01 134970884                          /usr/bin/php55
00613000-00615000 rw-p 00013000 08:01 134970884                          /usr/bin/php55
00eb3000-0133c000 rw-p 00000000 00:00 0                                  [heap]
7f95d0000000-7f95d0021000 rw-p 00000000 00:00 0 
7f95d0021000-7f95d4000000 ---p 00000000 00:00 0 
7f95d7cec000-7f95d7d12000 r-xp 00000000 08:01 134970886                  /usr/lib64/php55/hash.so
7f95d7d12000-7f95d7f12000 ---p 00026000 08:01 134970886                  /usr/lib64/php55/hash.so
7f95d7f12000-7f95d7f14000 r--p 00026000 08:01 134970886                  /usr/lib64/php55/hash.so
7f95d7f14000-7f95d7f15000 rw-p 00028000 08:01 134970886                  /usr/lib64/php55/hash.so
7f95d87ca000-7f95d88d8000 r-xp 00000000 08:01 271091978                  /usr/lib64/libglib-2.0.so.0.4800.1
7f95d88d8000-7f95d8ad7000 ---p 0010e000 08:01 271091978                  /usr/lib64/libglib-2.0.so.0.4800.1
7f95d8ad7000-7f95d8ad8000 r--p 0010d000 08:01 271091978                  /usr/lib64/libglib-2.0.so.0.4800.1
7f95d8ad8000-7f95d8ad9000 rw-p 0010e000 08:01 271091978                  /usr/lib64/libglib-2.0.so.0.4800.1
7f95d8ad9000-7f95d8ada000 rw-p 00000000 00:00 0 
7f95db448000-7f95db461000 r-xp 00000000 08:01 402740831                  /lib64/libaudit.so.1.0.0
7f95db461000-7f95db660000 ---p 00019000 08:01 402740831                  /lib64/libaudit.so.1.0.0
7f95db660000-7f95db661000 r--p 00018000 08:01 402740831                  /lib64/libaudit.so.1.0.0
7f95db661000-7f95db662000 rw-p 00019000 08:01 402740831                  /lib64/libaudit.so.1.0.0
7f95db662000-7f95db66c000 rw-p 00000000 00:00 0 
7f95db66c000-7f95db67a000 r-xp 00000000 08:01 402813014                  /lib64/libpam.so.0.84.2
7f95db67a000-7f95db879000 ---p 0000e000 08:01 402813014                  /lib64/libpam.so.0.84.2
7f95db879000-7f95db87a000 r--p 0000d000 08:01 402813014                  /lib64/libpam.so.0.84.2
7f95db87a000-7f95db87b000 rw-p 0000e000 08:01 402813014                  /lib64/libpam.so.0.84.2
7f95db87b000-7f95db949000 r-xp 00000000 08:01 402697172                  /lib64/libsqlite3.so.0.8.6
7f95db949000-7f95dbb49000 ---p 000ce000 08:01 402697172                  /lib64/libsqlite3.so.0.8.6
7f95dbb49000-7f95dbb4b000 r--p 000ce000 08:01 402697172                  /lib64/libsqlite3.so.0.8.6
7f95dbb4b000-7f95dbb4e000 rw-p 000d0000 08:01 402697172                  /lib64/libsqlite3.so.0.8.6
7f95dbb4e000-7f95dbb76000 r-xp 00000000 08:01 402655106                  /lib64/libwind.so.0.0.0
7f95dbb76000-7f95dbd75000 ---p 00028000 08:01 402655106                  /lib64/libwind.so.0.0.0
7f95dbd75000-7f95dbd76000 r--p 00027000 08:01 402655106                  /lib64/libwind.so.0.0.0
7f95dbd76000-7f95dbd77000 rw-p 00028000 08:01 402655106                  /lib64/libwind.so.0.0.0
7f95dbd77000-7f95dbdbc000 r-xp 00000000 08:01 402655102                  /lib64/libhx509.so.5.0.0
7f95dbdbc000-7f95dbfbc000 ---p 00045000 08:01 402655102                  /lib64/libhx509.so.5.0.0
7f95dbfbc000-7f95dbfbf000 r--p 00045000 08:01 402655102                  /lib64/libhx509.so.5.0.0
7f95dbfbf000-7f95dbfc1000 rw-p 00048000 08:01 402655102                  /lib64/libhx509.so.5.0.0
7f95dbfc1000-7f95dbfc2000 rw-p 00000000 00:00 0 
7f95dbfc2000-7f95dd83e000 r--p 00000000 08:01 270490253                  /usr/lib64/libicudata.so.57.1
7f95dd83e000-7f95dda3d000 ---p 0187c000 08:01 270490253                  /usr/lib64/libicudata.so.57.1
7f95dda3d000-7f95dda3e000 r--p 0187b000 08:01 270490253                  /usr/lib64/libicudata.so.57.1
7f95dda3e000-7f95dda5a000 r-xp 00000000 08:01 268870900                  /usr/lib64/libsasl2.so.3.0.0
7f95dda5a000-7f95ddc5a000 ---p 0001c000 08:01 268870900                  /usr/lib64/libsasl2.so.3.0.0
7f95ddc5a000-7f95ddc5b000 rw-p 0001c000 08:01 268870900                  /usr/lib64/libsasl2.so.3.0.0
7f95ddc5b000-7f95ddc6f000 r-xp 00000000 08:01 402655105                  /lib64/libroken.so.18.1.0
7f95ddc6f000-7f95dde6e000 ---p 00014000 08:01 402655105                  /lib64/libroken.so.18.1.0
7f95dde6e000-7f95dde6f000 r--p 00013000 08:01 402655105                  /lib64/libroken.so.18.1.0
7f95dde6f000-7f95dde70000 rw-p 00014000 08:01 402655105                  /lib64/libroken.so.18.1.0
7f95dde70000-7f95dde73000 r-xp 00000000 08:01 402740830                  /lib64/libcom_err.so.2.1
7f95dde73000-7f95de072000 ---p 00003000 08:01 402740830                  /lib64/libcom_err.so.2.1
7f95de072000-7f95de073000 r--p 00002000 08:01 402740830                  /lib64/libcom_err.so.2.1
7f95de073000-7f95de074000 rw-p 00003000 08:01 402740830                  /lib64/libcom_err.so.2.1
7f95de074000-7f95de111000 r-xp 00000000 08:01 402655097                  /lib64/libasn1.so.8.0.0
7f95de111000-7f95de310000 ---p 0009d000 08:01 402655097                  /lib64/libasn1.so.8.0.0
7f95de310000-7f95de312000 r--p 0009c000 08:01 402655097                  /lib64/libasn1.so.8.0.0
7f95de312000-7f95de316000 rw-p 0009e000 08:01 402655097                  /lib64/libasn1.so.8.0.0
7f95de316000-7f95de348000 r-xp 00000000 08:01 402655099                  /lib64/libhcrypto.so.4.1.0
7f95de348000-7f95de547000 ---p 00032000 08:01 402655099                  /lib64/libhcrypto.so.4.1.0
7f95de547000-7f95de549000 r--p 00031000 08:01 402655099                  /lib64/libhcrypto.so.4.1.0
7f95de549000-7f95de54a000 rw-p 00033000 08:01 402655099                  /lib64/libhcrypto.so.4.1.0
7f95de54a000-7f95de54b000 rw-p 00000000 00:00 0 
7f95de54b000-7f95de54e000 r-xp 00000000 08:01 402655100                  /lib64/libheimbase.so.1.0.0
7f95de54e000-7f95de74e000 ---p 00003000 08:01 402655100                  /lib64/libheimbase.so.1.0.0
7f95de74e000-7f95de74f000 r--p 00003000 08:01 402655100                  /lib64/libheimbase.so.1.0.0
7f95de74f000-7f95de750000 rw-p 00004000 08:01 402655100                  /lib64/libheimbase.so.1.0.0
7f95de750000-7f95de7cb000 r-xp 00000000 08:01 402655104                  /lib64/libkrb5.so.26.0.0
7f95de7cb000-7f95de9ca000 ---p 0007b000 08:01 402655104                  /lib64/libkrb5.so.26.0.0
7f95de9ca000-7f95de9cd000 r--p 0007a000 08:01 402655104                  /lib64/libkrb5.so.26.0.0
7f95de9cd000-7f95de9d1000 rw-p 0007d000 08:01 402655104                  /lib64/libkrb5.so.26.0.0
7f95de9d1000-7f95de9d7000 r-xp 00000000 08:01 402655101                  /lib64/libheimntlm.so.0.1.0
7f95de9d7000-7f95debd6000 ---p 00006000 08:01 402655101                  /lib64/libheimntlm.so.0.1.0
7f95debd6000-7f95debd7000 r--p 00005000 08:01 402655101                  /lib64/libheimntlm.so.0.1.0
7f95debd7000-7f95debd8000 rw-p 00006000 08:01 402655101                  /lib64/libheimntlm.so.0.1.0
7f95debd8000-7f95ded6c000 r-xp 00000000 08:01 270490260                  /usr/lib64/libicuuc.so.57.1
7f95ded6c000-7f95def6c000 ---p 00194000 08:01 270490260                  /usr/lib64/libicuuc.so.57.1
7f95def6c000-7f95def7e000 r--p 00194000 08:01 270490260                  /usr/lib64/libicuuc.so.57.1
7f95def7e000-7f95def7f000 rw-p 001a6000 08:01 270490260                  /usr/lib64/libicuuc.so.57.1
7f95def7f000-7f95def81000 rw-p 00000000 00:00 0 
7f95def81000-7f95df1b0000 r-xp 00000000 08:01 402796622                  /lib64/libcrypto.so.1.0.0
7f95df1b0000-7f95df3b0000 ---p 0022f000 08:01 402796622                  /lib64/libcrypto.so.1.0.0
7f95df3b0000-7f95df3d7000 rw-p 0022f000 08:01 402796622                  /lib64/libcrypto.so.1.0.0
7f95df3d7000-7f95df3db000 rw-p 00000000 00:00 0 
7f95df3db000-7f95df446000 r-xp 00000000 08:01 402796623                  /lib64/libssl.so.1.0.0
7f95df446000-7f95df645000 ---p 0006b000 08:01 402796623                  /lib64/libssl.so.1.0.0
7f95df645000-7f95df650000 rw-p 0006a000 08:01 402796623                  /lib64/libssl.so.1.0.0
7f95df650000-7f95df65e000 r-xp 00000000 08:01 268871088                  /usr/lib64/liblber-2.4.so.2.10.6
7f95df65e000-7f95df85d000 ---p 0000e000 08:01 268871088                  /usr/lib64/liblber-2.4.so.2.10.6
7f95df85d000-7f95df85e000 r--p 0000d000 08:01 268871088                  /usr/lib64/liblber-2.4.so.2.10.6
7f95df85e000-7f95df85f000 rw-p 0000e000 08:01 268871088                  /usr/lib64/liblber-2.4.so.2.10.6
7f95df85f000-7f95df8a8000 r-xp 00000000 08:01 268871089                  /usr/lib64/libldap-2.4.so.2.10.6
7f95df8a8000-7f95dfaa8000 ---p 00049000 08:01 268871089                  /usr/lib64/libldap-2.4.so.2.10.6
7f95dfaa8000-7f95dfaa9000 r--p 00049000 08:01 268871089                  /usr/lib64/libldap-2.4.so.2.10.6
7f95dfaa9000-7f95dfaab000 rw-p 0004a000 08:01 268871089                  /usr/lib64/libldap-2.4.so.2.10.6
7f95dfaab000-7f95dfae6000 r-xp 00000000 08:01 402655098                  /lib64/libgssapi.so.3.0.0
7f95dfae6000-7f95dfce6000 ---p 0003b000 08:01 402655098                  /lib64/libgssapi.so.3.0.0
7f95dfce6000-7f95dfce7000 r--p 0003b000 08:01 402655098                  /lib64/libgssapi.so.3.0.0
7f95dfce7000-7f95dfcea000 rw-p 0003c000 08:01 402655098                  /lib64/libgssapi.so.3.0.0
7f95dfcea000-7f95dfcf5000 r-xp 00000000 08:01 269457701                  /usr/lib64/libpsl.so.5.0.0
7f95dfcf5000-7f95dfef5000 ---p 0000b000 08:01 269457701                  /usr/lib64/libpsl.so.5.0.0
7f95dfef5000-7f95dfef6000 r--p 0000b000 08:01 269457701                  /usr/lib64/libpsl.so.5.0.0
7f95dfef6000-7f95dfef7000 rw-p 0000c000 08:01 269457701                  /usr/lib64/libpsl.so.5.0.0
7f95dfef7000-7f95dff23000 r-xp 00000000 08:01 268827993                  /usr/lib64/libssh2.so.1.0.1
7f95dff23000-7f95e0123000 ---p 0002c000 08:01 268827993                  /usr/lib64/libssh2.so.1.0.1
7f95e0123000-7f95e0124000 r--p 0002c000 08:01 268827993                  /usr/lib64/libssh2.so.1.0.1
7f95e0124000-7f95e0125000 rw-p 0002d000 08:01 268827993                  /usr/lib64/libssh2.so.1.0.1
7f95e0125000-7f95e013c000 r-xp 00000000 08:01 270314764                  /usr/lib64/librtmp.so.0.0.0
7f95e013c000-7f95e033c000 ---p 00017000 08:01 270314764                  /usr/lib64/librtmp.so.0.0.0
7f95e033c000-7f95e033d000 r--p 00017000 08:01 270314764                  /usr/lib64/librtmp.so.0.0.0
7f95e033d000-7f95e033e000 rw-p 00018000 08:01 270314764                  /usr/lib64/librtmp.so.0.0.0
7f95e033e000-7f95e0370000 r-xp 00000000 08:01 268692046                  /usr/lib64/libidn.so.11.6.15
7f95e0370000-7f95e0570000 ---p 00032000 08:01 268692046                  /usr/lib64/libidn.so.11.6.15
7f95e0570000-7f95e0571000 r--p 00032000 08:01 268692046                  /usr/lib64/libidn.so.11.6.15
7f95e0571000-7f95e0572000 rw-p 00033000 08:01 268692046                  /usr/lib64/libidn.so.11.6.15
7f95e0572000-7f95e0595000 r-xp 00000000 08:01 268871041                  /usr/lib64/libnghttp2.so.14.8.0
7f95e0595000-7f95e0794000 ---p 00023000 08:01 268871041                  /usr/lib64/libnghttp2.so.14.8.0
7f95e0794000-7f95e0795000 r--p 00022000 08:01 268871041                  /usr/lib64/libnghttp2.so.14.8.0
7f95e0795000-7f95e0798000 rw-p 00023000 08:01 268871041                  /usr/lib64/libnghttp2.so.14.8.0
7f95e0798000-7f95e07a9000 r-xp 00000000 08:01 270314766                  /usr/lib64/libcares.so.2.1.0
7f95e07a9000-7f95e09a8000 ---p 00011000 08:01 270314766                  /usr/lib64/libcares.so.2.1.0
7f95e09a8000-7f95e09a9000 r--p 00010000 08:01 270314766                  /usr/lib64/libcares.so.2.1.0
7f95e09a9000-7f95e09aa000 rw-p 00011000 08:01 270314766                  /usr/lib64/libcares.so.2.1.0
7f95e09aa000-7f95e0a23000 r-xp 00000000 08:01 269659441                  /usr/lib64/libcurl.so.4.4.0
7f95e0a23000-7f95e0c23000 ---p 00079000 08:01 269659441                  /usr/lib64/libcurl.so.4.4.0
7f95e0c23000-7f95e0c25000 r--p 00079000 08:01 269659441                  /usr/lib64/libcurl.so.4.4.0
7f95e0c25000-7f95e0c27000 rw-p 0007b000 08:01 269659441                  /usr/lib64/libcurl.so.4.4.0
7f95e0c27000-7f95e0c3b000 r-xp 00000000 08:01 135987657                  /usr/lib64/php55/curl.so
7f95e0c3b000-7f95e0e3a000 ---p 00014000 08:01 135987657                  /usr/lib64/php55/curl.so
7f95e0e3a000-7f95e0e3c000 r--p 00013000 08:01 135987657                  /usr/lib64/php55/curl.so
7f95e0e3c000-7f95e0e3d000 rw-p 00015000 08:01 135987657                  /usr/lib64/php55/curl.so
7f95e0e3d000-7f95e0e40000 r-xp 00000000 08:01 135414442                  /usr/lib64/php55/ctype.so
7f95e0e40000-7f95e103f000 ---p 00003000 08:01 135414442                  /usr/lib64/php55/ctype.so
7f95e103f000-7f95e1040000 r--p 00002000 08:01 135414442                  /usr/lib64/php55/ctype.so
7f95e1040000-7f95e1041000 rw-p 00003000 08:01 135414442                  /usr/lib64/php55/ctype.so
7f95e1041000-7f95e1048000 r-xp 00000000 08:01 135987652                  /usr/lib64/php55/calendar.so
7f95e1048000-7f95e1248000 ---p 00007000 08:01 135987652                  /usr/lib64/php55/calendar.so
7f95e1248000-7f95e1249000 r--p 00007000 08:01 135987652                  /usr/lib64/php55/calendar.so
7f95e1249000-7f95e124a000 rw-p 00008000 08:01 135987652                  /usr/lib64/php55/calendar.so
7f95e124a000-7f95e1259000 r-xp 00000000 08:01 402654274                  /lib64/libbz2.so.1.0.0
7f95e1259000-7f95e1458000 ---p 0000f000 08:01 402654274                  /lib64/libbz2.so.1.0.0
7f95e1458000-7f95e145a000 r--p 0000e000 08:01 402654274                  /lib64/libbz2.so.1.0.0
7f95e145a000-7f95e145b000 rw-p 00010000 08:01 402654274                  /lib64/libbz2.so.1.0.0
7f95e145b000-7f95e1460000 r-xp 00000000 08:01 135959240                  /usr/lib64/php55/bz2.so
7f95e1460000-7f95e165f000 ---p 00005000 08:01 135959240                  /usr/lib64/php55/bz2.so
7f95e165f000-7f95e1660000 r--p 00004000 08:01 135959240                  /usr/lib64/php55/bz2.so
7f95e1660000-7f95e1661000 rw-p 00005000 08:01 135959240                  /usr/lib64/php55/bz2.so
7f95e1661000-7f95e1669000 r-xp 00000000 08:01 135414438                  /usr/lib64/php55/bcmath.so
7f95e1669000-7f95e1868000 ---p 00008000 08:01 135414438                  /usr/lib64/php55/bcmath.so
7f95e1868000-7f95e1869000 r--p 00007000 08:01 135414438                  /usr/lib64/php55/bcmath.so
7f95e1869000-7f95e186a000 rw-p 00008000 08:01 135414438                  /usr/lib64/php55/bcmath.so
7f95e186a000-7f95e187c000 r-xp 00000000 08:01 135414462                  /usr/lib64/php55/session.so
7f95e187c000-7f95e1a7c000 ---p 00012000 08:01 135414462                  /usr/lib64/php55/session.so
7f95e1a7c000-7f95e1a7e000 r--p 00012000 08:01 135414462                  /usr/lib64/php55/session.so
7f95e1a7e000-7f95e1a7f000 rw-p 00014000 08:01 135414462                  /usr/lib64/php55/session.so
7f95e1a7f000-7f95e1ac3000 r-xp 00000000 08:01 135824148                  /usr/lib64/php55/spl.so
7f95e1ac3000-7f95e1cc3000 ---p 00044000 08:01 135824148                  /usr/lib64/php55/spl.so
7f95e1cc3000-7f95e1cc9000 r--p 00044000 08:01 135824148                  /usr/lib64/php55/spl.so
7f95e1cc9000-7f95e1cca000 rw-p 0004a000 08:01 135824148                  /usr/lib64/php55/spl.so
7f95e1cca000-7f95e1ccb000 rw-p 00000000 00:00 0 
7f95e1ccb000-7f95e1cd3000 r-xp 00000000 08:01 135832895                  /usr/lib64/php55/pcre.so
7f95e1cd3000-7f95e1ed3000 ---p 00008000 08:01 135832895                  /usr/lib64/php55/pcre.so
7f95e1ed3000-7f95e1ed4000 r--p 00008000 08:01 135832895                  /usr/lib64/php55/pcre.so
7f95e1ed4000-7f95e1ed5000 rw-p 00009000 08:01 135832895                  /usr/lib64/php55/pcre.so
7f95e1ed5000-7f95e2029000 r-xp 00000000 08:01 135824167                  /usr/lib64/php55/ioncube.so
7f95e2029000-7f95e2128000 ---p 00154000 08:01 135824167                  /usr/lib64/php55/ioncube.so
7f95e2128000-7f95e2136000 rw-p 00153000 08:01 135824167                  /usr/lib64/php55/ioncube.so
7f95e2136000-7f95e2139000 rw-p 00000000 00:00 0 
7f95e2139000-7f95e214f000 r-xp 00000000 08:01 402996279                  /lib64/libgcc_s.so.1
7f95e214f000-7f95e234e000 ---p 00016000 08:01 402996279                  /lib64/libgcc_s.so.1
7f95e234e000-7f95e234f000 rw-p 00015000 08:01 402996279                  /lib64/libgcc_s.so.1
7f95e234f000-7f95e2351000 r-xp 00000000 08:01 402654283                  /lib64/libfreebl3.so
7f95e2351000-7f95e2550000 ---p 00002000 08:01 402654283                  /lib64/libfreebl3.so
7f95e2550000-7f95e2551000 rw-p 00001000 08:01 402654283                  /lib64/libfreebl3.so
7f95e2551000-7f95e26ec000 r-xp 00000000 08:01 402653732                  /lib64/libc-2.23.so
7f95e26ec000-7f95e28eb000 ---p 0019b000 08:01 402653732                  /lib64/libc-2.23.so
7f95e28eb000-7f95e28ef000 r--p 0019a000 08:01 402653732                  /lib64/libc-2.23.so
7f95e28ef000-7f95e28f1000 rw-p 0019e000 08:01 402653732                  /lib64/libc-2.23.so
7f95e28f1000-7f95e28f5000 rw-p 00000000 00:00 0 
7f95e28f5000-7f95e290d000 r-xp 00000000 08:01 403589169                  /lib64/libpthread-2.23.so
7f95e290d000-7f95e2b0c000 ---p 00018000 08:01 403589169                  /lib64/libpthread-2.23.so
7f95e2b0c000-7f95e2b0d000 r--p 00017000 08:01 403589169                  /lib64/libpthread-2.23.so
7f95e2b0d000-7f95e2b0e000 rw-p 00018000 08:01 403589169                  /lib64/libpthread-2.23.so
7f95e2b0e000-7f95e2b12000 rw-p 00000000 00:00 0 
7f95e2b12000-7f95e2b7a000 r-xp 00000000 08:01 402694125                  /lib64/libncursesw.so.6.0
7f95e2b7a000-7f95e2d7a000 ---p 00068000 08:01 402694125                  /lib64/libncursesw.so.6.0
7f95e2d7a000-7f95e2d7e000 r--p 00068000 08:01 402694125                  /lib64/libncursesw.so.6.0
7f95e2d7e000-7f95e2d80000 rw-p 0006c000 08:01 402694125                  /lib64/libncursesw.so.6.0
7f95e2d80000-7f95e2dbf000 r-xp 00000000 08:01 402654438                  /lib64/libreadline.so.6.3
7f95e2dbf000-7f95e2fbf000 ---p 0003f000 08:01 402654438                  /lib64/libreadline.so.6.3
7f95e2fbf000-7f95e2fc2000 r--p 0003f000 08:01 402654438                  /lib64/libreadline.so.6.3
7f95e2fc2000-7f95e2fc9000 rw-p 00042000 08:01 402654438                  /lib64/libreadline.so.6.3
7f95e2fc9000-7f95e2fca000 rw-p 00000000 00:00 0 
7f95e2fca000-7f95e2fef000 r-xp 00000000 08:01 402654177                  /lib64/liblzma.so.5.2.2
7f95e2fef000-7f95e31ee000 ---p 00025000 08:01 402654177                  /lib64/liblzma.so.5.2.2
7f95e31ee000-7f95e31ef000 r--p 00024000 08:01 402654177                  /lib64/liblzma.so.5.2.2
7f95e31ef000-7f95e31f0000 rw-p 00025000 08:01 402654177                  /lib64/liblzma.so.5.2.2
7f95e31f0000-7f95e3205000 r-xp 00000000 08:01 402654020                  /lib64/libz.so.1.2.8
7f95e3205000-7f95e3404000 ---p 00015000 08:01 402654020                  /lib64/libz.so.1.2.8
7f95e3404000-7f95e3405000 rw-p 00014000 08:01 402654020                  /lib64/libz.so.1.2.8
7f95e3405000-7f95e3563000 r-xp 00000000 08:01 269457715                  /usr/lib64/libxml2.so.2.9.4
7f95e3563000-7f95e3763000 ---p 0015e000 08:01 269457715                  /usr/lib64/libxml2.so.2.9.4
7f95e3763000-7f95e376b000 r--p 0015e000 08:01 269457715                  /usr/lib64/libxml2.so.2.9.4
7f95e376b000-7f95e376d000 rw-p 00166000 08:01 269457715                  /usr/lib64/libxml2.so.2.9.4
7f95e376d000-7f95e376e000 rw-p 00000000 00:00 0 
7f95e376e000-7f95e3775000 r-xp 00000000 08:01 403589173                  /lib64/librt-2.23.so
7f95e3775000-7f95e3974000 ---p 00007000 08:01 403589173                  /lib64/librt-2.23.so
7f95e3974000-7f95e3975000 r--p 00006000 08:01 403589173                  /lib64/librt-2.23.so
7f95e3975000-7f95e3976000 rw-p 00007000 08:01 403589173                  /lib64/librt-2.23.so
7f95e3976000-7f95e3ae8000 r-xp 00000000 08:01 268687464                  /usr/lib64/libstdc++.so.6.0.21
7f95e3ae8000-7f95e3ce8000 ---p 00172000 08:01 268687464                  /usr/lib64/libstdc++.so.6.0.21
7f95e3ce8000-7f95e3cf2000 r--p 00172000 08:01 268687464                  /usr/lib64/libstdc++.so.6.0.21
7f95e3cf2000-7f95e3cf4000 rw-p 0017c000 08:01 268687464                  /usr/lib64/libstdc++.so.6.0.21
7f95e3cf4000-7f95e3cf8000 rw-p 00000000 00:00 0 
7f95e3cf8000-7f95e3d0c000 r-xp 00000000 08:01 403589171                  /lib64/libresolv-2.23.so
7f95e3d0c000-7f95e3f0c000 ---p 00014000 08:01 403589171                  /lib64/libresolv-2.23.so
7f95e3f0c000-7f95e3f0d000 r--p 00014000 08:01 403589171                  /lib64/libresolv-2.23.so
7f95e3f0d000-7f95e3f0e000 rw-p 00015000 08:01 403589171                  /lib64/libresolv-2.23.so
7f95e3f0e000-7f95e3f10000 rw-p 00000000 00:00 0
7f95e3f10000-7f95e3f81000 r-xp 00000000 08:01 403194900                  /lib64/libpcre.so.1.2.7
7f95e3f81000-7f95e4180000 ---p 00071000 08:01 403194900                  /lib64/libpcre.so.1.2.7
7f95e4180000-7f95e4181000 r--p 00070000 08:01 403194900                  /lib64/libpcre.so.1.2.7
7f95e4181000-7f95e4182000 rw-p 00071000 08:01 403194900                  /lib64/libpcre.so.1.2.7
7f95e4182000-7f95e4184000 r-xp 00000000 08:01 402653736                  /lib64/libdl-2.23.so
7f95e4184000-7f95e4384000 ---p 00002000 08:01 402653736                  /lib64/libdl-2.23.so
7f95e4384000-7f95e4385000 r--p 00002000 08:01 402653736                  /lib64/libdl-2.23.so
7f95e4385000-7f95e4386000 rw-p 00003000 08:01 402653736                  /lib64/libdl-2.23.so
7f95e4386000-7f95e448a000 r-xp 00000000 08:01 402653738                  /lib64/libm-2.23.so
7f95e448a000-7f95e4689000 ---p 00104000 08:01 402653738                  /lib64/libm-2.23.so
7f95e4689000-7f95e468a000 r--p 00103000 08:01 402653738                  /lib64/libm-2.23.so
7f95e468a000-7f95e468b000 rw-p 00104000 08:01 402653738                  /lib64/libm-2.23.so
7f95e468b000-7f95e4695000 r-xp 00000000 08:01 402653974                  /lib64/libcrypt-2.23.so
7f95e4695000-7f95e4895000 ---p 0000a000 08:01 402653974                  /lib64/libcrypt-2.23.so
7f95e4895000-7f95e4896000 r--p 0000a000 08:01 402653974                  /lib64/libcrypt-2.23.so
7f95e4896000-7f95e4897000 rw-p 0000b000 08:01 402653974                  /lib64/libcrypt-2.23.so
7f95e4897000-7f95e48c5000 rw-p 00000000 00:00 0
7f95e48c5000-7f95e4bdc000 r-xp 00000000 08:01 268646744                  /usr/lib64/libphp_common-5.5.36.so
7f95e4bdc000-7f95e4ddc000 ---p 00317000 08:01 268646744                  /usr/lib64/libphp_common-5.5.36.so
7f95e4ddc000-7f95e4e58000 rw-p 00317000 08:01 268646744                  /usr/lib64/libphp_common-5.5.36.so
7f95e4e58000-7f95e4e71000 rw-p 00000000 00:00 0
7f95e4e71000-7f95e4e94000 r-xp 00000000 08:01 403589154                  /lib64/ld-2.23.so
7f95e4eaa000-7f95e4edf000 r--s 00000000 08:01 270489856                  /var/lib/nscd/services
7f95e4eef000-7f95e508b000 rw-p 00000000 00:00 0
7f95e5092000-7f95e5094000 rw-p 00000000 00:00 0
7f95e5094000-7f95e5095000 r--p 00023000 08:01 403589154                  /lib64/ld-2.23.so
7f95e5095000-7f95e5096000 rw-p 00024000 08:01 403589154                  /lib64/ld-2.23.so
7f95e5096000-7f95e5097000 rw-p 00000000 00:00 0
7ffe05cf1000-7ffe05d12000 rw-p 00000000 00:00 0                          [stack]
7ffe05df8000-7ffe05dfa000 r--p 00000000 00:00 0                          [vvar]
7ffe05dfa000-7ffe05dfc000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]

arekm added a commit to pld-linux/curl that referenced this issue Jul 6, 2016
@jay
Copy link
Member

@jay jay commented Jul 6, 2016

@arekm Start a new issue please. I reviewed OpenSSL 1.0.2h and I don't see that it calls SSL_COMP_free_compression_methods internally, therefore I still think what we are doing is correct. If you ask libcurl to initialize openssl then logically it follows when libcurl cleans up it's going to clean up openssl. It's possible something in PHP is calling that function or is calling curl global cleanup concurrently.

@arekm
Copy link

@arekm arekm commented Jul 6, 2016

@jay: My guess about the issue is like this: consider php which uses openssl internally, php-pgsql where libpgsql uses openssl internally, php-curl. All that three things used in one single 'php' binary. Now curl is being ended, does its cleanup and decides to free global data. Then php-openssl and php-libpgsql still try to do something openssl related where openssl needs that global data for that. Result -> crash. (but that's only my guess)

Opening new issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants