<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, May 8, 2019 at 1:29 PM Zhou, Cynthia (NSB - CN/Hangzhou) <<a href="mailto:cynthia.zhou@nokia-sbell.com">cynthia.zhou@nokia-sbell.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="ZH-CN">
<div class="gmail-m_-1109814905353783812WordSection1">
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">Hi 'Milind Changire' ,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">The leak is getting more and more clear to me now. the unsolved memory leak is because of in gluterfs version 3.12.15 (in my env)the ssl context is a shared one, while we
do ssl_acept, ssl will allocate some read/write buffer to ssl object, however, ssl_free in socket_reset or fini function of socket.c, the buffer is returened back to ssl context free list instead of completely freed.</span></p></div></div></blockquote><div><br></div><div>Thanks Cynthia for your efforts in identifying and fixing the leak. If you post a patch to gerrit, I'll be happy to merge it and get the fix into the codebase.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="ZH-CN"><div class="gmail-m_-1109814905353783812WordSection1"><p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">So following patch is able to fix the memory leak issue completely.(created for gluster master branch)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">--- a/rpc/rpc-transport/socket/src/socket.c<br>
+++ b/rpc/rpc-transport/socket/src/socket.c<br>
@@ -446,6 +446,7 @@ ssl_setup_connection_postfix(rpc_transport_t *this)<br>
gf_log(this->name, GF_LOG_DEBUG,<br>
"SSL verification succeeded (client: %s) (server: %s)",<br>
this->peerinfo.identifier, this->myinfo.identifier);<br>
+ X509_free(peer);<br>
return gf_strdup(peer_CN);<br>
<br>
/* Error paths. */<br>
@@ -1157,7 +1158,21 @@ __socket_reset(rpc_transport_t *this)<br>
memset(&priv->incoming, 0, sizeof(priv->incoming));<br>
<br>
event_unregister_close(this->ctx->event_pool, priv->sock, priv->idx);<br>
-<br>
+ if(priv->use_ssl&& priv->ssl_ssl)<br>
+ {<br>
+ gf_log(this->name, GF_LOG_TRACE,<br>
+ "clear and reset for socket(%d), free ssl ",<br>
+ priv->sock);<br>
+ if(priv->ssl_ctx)<br>
+ {<br>
+ SSL_CTX_free(priv->ssl_ctx);<br>
+ priv->ssl_ctx = NULL;<br>
+ }<br>
+ SSL_shutdown(priv->ssl_ssl);<br>
+ SSL_clear(priv->ssl_ssl);<br>
+ SSL_free(priv->ssl_ssl);<br>
+ priv->ssl_ssl = NULL;<br>
+ }<br>
priv->sock = -1;<br>
priv->idx = -1;<br>
priv->connected = -1;<br>
@@ -4675,6 +4690,21 @@ fini(rpc_transport_t *this)<br>
pthread_mutex_destroy(&priv->out_lock);<br>
pthread_mutex_destroy(&priv->cond_lock);<br>
pthread_cond_destroy(&priv->cond);<br>
+ if(priv->use_ssl&& priv->ssl_ssl)<br>
+ {<br>
+ gf_log(this->name, GF_LOG_TRACE,<br>
+ "clear and reset for socket(%d), free ssl ",<br>
+ priv->sock);<br>
+ if(priv->ssl_ctx)<br>
+ {<br>
+ SSL_CTX_free(priv->ssl_ctx);<br>
+ priv->ssl_ctx = NULL;<br>
+ }<br>
+ SSL_shutdown(priv->ssl_ssl);<br>
+ SSL_clear(priv->ssl_ssl);<br>
+ SSL_free(priv->ssl_ssl);</span><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u><u></u></span></p>
<div>
<div style="border-color:rgb(225,225,225) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:11pt;font-family:"Calibri",sans-serif" lang="EN-US">From:</span></b><span style="font-size:11pt;font-family:"Calibri",sans-serif" lang="EN-US"> Zhou, Cynthia (NSB - CN/Hangzhou)
<br>
<b>Sent:</b> Monday, May 06, 2019 2:12 PM<br>
<b>To:</b> 'Amar Tumballi Suryanarayan' <<a href="mailto:atumball@redhat.com" target="_blank">atumball@redhat.com</a>><br>
<b>Cc:</b> 'Milind Changire' <<a href="mailto:mchangir@redhat.com" target="_blank">mchangir@redhat.com</a>>; '<a href="mailto:gluster-devel@gluster.org" target="_blank">gluster-devel@gluster.org</a>' <<a href="mailto:gluster-devel@gluster.org" target="_blank">gluster-devel@gluster.org</a>><br>
<b>Subject:</b> RE: [Gluster-devel] glusterfsd memory leak issue found after enable ssl<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">From our test valgrind and libleak all blame ssl3_accept<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">///////////////////////////from valgrind attached to glusterfds///////////////////////////////////////////<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US">==16673== 198,720 bytes in 12 blocks are definitely lost in loss record 1,114 of 1,123<br>
==16673== at 0x4C2EB7B: malloc (vg_replace_malloc.c:299)<br>
==16673== by 0x63E1977: CRYPTO_malloc (in /usr/lib64/<u><span style="color:blue">libcrypto.so.1.0.2p</span></u>)<br>
==16673== by 0xA855E0C: ssl3_setup_write_buffer (in /usr/lib64/<u><span style="color:blue">libssl.so.1.0.2p</span></u>)<br>
==16673== by 0xA855E77: ssl3_setup_buffers (in /usr/lib64/<u><span style="color:blue">libssl.so.1.0.2p</span></u>)<br>
==16673== by 0xA8485D9: <span style="color:red">ssl3_accept</span> (in /usr/lib64/<u><span style="color:blue">libssl.so.1.0.2p</span></u>)<br>
==16673== by 0xA610DDF: ssl_complete_connection (socket.c:400)<br>
==16673== by 0xA617F38: ssl_handle_server_connection_attempt (socket.c:2409)<br>
==16673== by 0xA618420: socket_complete_connection (socket.c:2554)<br>
==16673== by 0xA618788: socket_event_handler (socket.c:2613)<br>
==16673== by 0x4ED6983: event_dispatch_epoll_handler (event-epoll.c:587)<br>
==16673== by 0x4ED6C5A: event_dispatch_epoll_worker (event-epoll.c:663)<br>
==16673== by 0x615C5D9: start_thread (in /usr/lib64/<u><span style="color:blue"><a href="http://libpthread-2.27.so" target="_blank">libpthread-2.27.so</a></span></u>)<br>
==16673==<br>
==16673== 200,544 bytes in 12 blocks are definitely lost in loss record 1,115 of 1,123<br>
==16673== at 0x4C2EB7B: malloc (vg_replace_malloc.c:299)<br>
==16673== by 0x63E1977: CRYPTO_malloc (in /usr/lib64/<u><span style="color:blue">libcrypto.so.1.0.2p</span></u>)<br>
==16673== by 0xA855D12: ssl3_setup_read_buffer (in /usr/lib64/<u><span style="color:blue">libssl.so.1.0.2p</span></u>)<br>
==16673== by 0xA855E68: ssl3_setup_buffers (in /usr/lib64/<u><span style="color:blue">libssl.so.1.0.2p</span></u>)<br>
==16673== by 0xA8485D9: <span style="color:red">ssl3_accept</span> (in /usr/lib64/<u><span style="color:blue">libssl.so.1.0.2p</span></u>)<br>
==16673== by 0xA610DDF: ssl_complete_connection (socket.c:400)<br>
==16673== by 0xA617F38: ssl_handle_server_connection_attempt (socket.c:2409)<br>
==16673== by 0xA618420: socket_complete_connection (socket.c:2554)<br>
==16673== by 0xA618788: socket_event_handler (socket.c:2613)<br>
==16673== by 0x4ED6983: event_dispatch_epoll_handler (event-epoll.c:587)<br>
==16673== by 0x4ED6C5A: event_dispatch_epoll_worker (event-epoll.c:663)<br>
==16673== by 0x615C5D9: start_thread (in /usr/lib64/<u><span style="color:blue"><a href="http://libpthread-2.27.so" target="_blank">libpthread-2.27.so</a></span></u>)<br>
==16673==<br>
valgrind --leak-check=f<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">////////////////////////////////////with libleak attached to glusterfsd/////////////////////////////////////////<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">callstack[2419] expires. count=1 size=224/224 alloc=362 free=350<br>
/home/robot/libleak/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libleak.so(malloc+0x25</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f1460604065]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libcrypto.so.10(CRYPTO_malloc+0x58</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145ecd9978]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libcrypto.so.10(EVP_DigestInit_ex+0x2a9</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145ed95749]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libssl.so.10(ssl3_digest_cached_records+0x11d</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145abb6ced]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libssl.so.10(</span></u><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:red" lang="EN-US">ssl3_accept</span></u><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">+0xc8f</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145abadc4f]<br>
/usr/lib64/glusterfs/3.12.15/rpc-transport/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">socket.so(ssl_complete_connection+0x5e</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145ae00f3a]<br>
/usr/lib64/glusterfs/3.12.15/rpc-transport/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">socket.so(+0xc16d</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145ae0816d]<br>
/usr/lib64/glusterfs/3.12.15/rpc-transport/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">socket.so(+0xc68a</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145ae0868a]<br>
/usr/lib64/glusterfs/3.12.15/rpc-transport/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">socket.so(+0xc9f2</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145ae089f2]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libglusterfs.so.0(+0x9b96f</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f146038596f]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libglusterfs.so.0(+0x9bc46</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f1460385c46]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libpthread.so.0(+0x75da</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145f0d15da]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libc.so.6(clone+0x3f</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145e9a7eaf]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">callstack[2432] expires. count=1 size=104/104 alloc=362 free=0<br>
/home/robot/libleak/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libleak.so(malloc+0x25</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f1460604065]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libcrypto.so.10(CRYPTO_malloc+0x58</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145ecd9978]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libcrypto.so.10(BN_MONT_CTX_new+0x17</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145ed48627]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libcrypto.so.10(BN_MONT_CTX_set_locked+0x6d</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145ed489fd]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libcrypto.so.10(+0xff4d9</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145ed6a4d9]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libcrypto.so.10(int_rsa_verify+0x1cd</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145ed6d41d]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libcrypto.so.10(RSA_verify+0x32</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145ed6d972]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libcrypto.so.10(+0x107ff5</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145ed72ff5]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libcrypto.so.10(EVP_VerifyFinal+0x211</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145ed9dd51]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libssl.so.10(ssl3_get_cert_verify+0x5bb</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145abac06b]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libssl.so.10(</span></u><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:red" lang="EN-US">ssl3_accept</span></u><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">+0x988</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145abad948]<br>
/usr/lib64/glusterfs/3.12.15/rpc-transport/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">socket.so(ssl_complete_connection+0x5e</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145ae00f3a]<br>
/usr/lib64/glusterfs/3.12.15/rpc-transport/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">socket.so(+0xc16d</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145ae0816d]<br>
/usr/lib64/glusterfs/3.12.15/rpc-transport/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">socket.so(+0xc68a</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145ae0868a]<br>
/usr/lib64/glusterfs/3.12.15/rpc-transport/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">socket.so(+0xc9f2</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">)
[0x7f145ae089f2]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libglusterfs.so.0(+0x9b96f</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f146038596f]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libglusterfs.so.0(+0x9bc46</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f1460385c46]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libpthread.so.0(+0x75da</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145f0d15da]<br>
/lib64/</span><u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:blue" lang="EN-US">libc.so.6(clone+0x3f</span></u><span style="font-size:10pt;font-family:"Segoe UI",sans-serif;color:rgb(26,26,26)" lang="EN-US">) [0x7f145e9a7eaf]<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:14pt;font-family:DengXian" lang="EN-US">one interesting thing is that the memory goes up to about 300m then it stopped increasing !!!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:14pt;font-family:DengXian" lang="EN-US">I am wondering if this is caused by open-ssl library? But when I search from openssl community, there is no such issue reported before.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:14pt;font-family:DengXian" lang="EN-US">Is glusterfs using ssl_accept correctly?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">cynthia<u></u><u></u></span></p>
<div>
<div style="border-color:rgb(225,225,225) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:11pt;font-family:"Calibri",sans-serif" lang="EN-US">From:</span></b><span style="font-size:11pt;font-family:"Calibri",sans-serif" lang="EN-US"> Zhou, Cynthia (NSB - CN/Hangzhou)
<br>
<b>Sent:</b> Monday, May 06, 2019 10:34 AM<br>
<b>To:</b> 'Amar Tumballi Suryanarayan' <<a href="mailto:atumball@redhat.com" target="_blank">atumball@redhat.com</a>><br>
<b>Cc:</b> Milind Changire <<a href="mailto:mchangir@redhat.com" target="_blank">mchangir@redhat.com</a>>;
<a href="mailto:gluster-devel@gluster.org" target="_blank">gluster-devel@gluster.org</a><br>
<b>Subject:</b> RE: [Gluster-devel] glusterfsd memory leak issue found after enable ssl<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">Hi,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">Sorry, I am so busy with other issues these days, could you help me to submit my patch for review? It is based on glusterfs3.12.15 code. But even with this patch , memory
leak still exists, from memory leak tool it should be related with ssl_accept, not sure if it is because of openssl library or because improper use of ssl interfaces.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">--- a/rpc/rpc-transport/socket/src/socket.c<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+++ b/rpc/rpc-transport/socket/src/socket.c<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">@@ -1019,7 +1019,16 @@ static void __socket_reset(rpc_transport_t *this) {<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> memset(&priv->incoming, 0, sizeof(priv->incoming));<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> event_unregister_close(this->ctx->event_pool, priv->sock, priv->idx);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">-<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ if(priv->use_ssl&& priv->ssl_ssl)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ {<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ gf_log(this->name, GF_LOG_INFO,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ "clear and reset for socket(%d), free ssl ",<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ priv->sock);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ SSL_shutdown(priv->ssl_ssl);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ SSL_clear(priv->ssl_ssl);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ SSL_free(priv->ssl_ssl);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ priv->ssl_ssl = NULL;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ }<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> priv->sock = -1;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> priv->idx = -1;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> priv->connected = -1;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">@@ -4238,6 +4250,16 @@ void fini(rpc_transport_t *this) {<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> pthread_mutex_destroy(&priv->out_lock);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> pthread_mutex_destroy(&priv->cond_lock);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> pthread_cond_destroy(&priv->cond);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ if(priv->use_ssl&& priv->ssl_ssl)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ {<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ gf_log(this->name, GF_LOG_INFO,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ "clear and reset for socket(%d), free ssl ",<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ priv->sock);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ SSL_shutdown(priv->ssl_ssl);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ SSL_clear(priv->ssl_ssl);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ SSL_free(priv->ssl_ssl);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ priv->ssl_ssl = NULL;<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">+ }<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> if (priv->ssl_private_key) {<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> GF_FREE(priv->ssl_private_key);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> }<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11pt;font-family:"Calibri",sans-serif" lang="EN-US">From:</span></b><span style="font-size:11pt;font-family:"Calibri",sans-serif" lang="EN-US"> Amar Tumballi Suryanarayan <<a href="mailto:atumball@redhat.com" target="_blank">atumball@redhat.com</a>>
<br>
<b>Sent:</b> Wednesday, May 01, 2019 8:43 PM<br>
<b>To:</b> Zhou, Cynthia (NSB - CN/Hangzhou) <<a href="mailto:cynthia.zhou@nokia-sbell.com" target="_blank">cynthia.zhou@nokia-sbell.com</a>><br>
<b>Cc:</b> Milind Changire <<a href="mailto:mchangir@redhat.com" target="_blank">mchangir@redhat.com</a>>;
<a href="mailto:gluster-devel@gluster.org" target="_blank">gluster-devel@gluster.org</a><br>
<b>Subject:</b> Re: [Gluster-devel] glusterfsd memory leak issue found after enable ssl<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US">Hi Cynthia Zhou,<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">Can you post the patch which fixes the issue of missing free? We will continue to investigate the leak further, but would really appreciate getting the patch which is already worked on land into upstream master.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">-Amar<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">On Mon, Apr 22, 2019 at 1:38 PM Zhou, Cynthia (NSB - CN/Hangzhou) <<a href="mailto:cynthia.zhou@nokia-sbell.com" target="_blank">cynthia.zhou@nokia-sbell.com</a>> wrote:<u></u><u></u></span></p>
</div>
<blockquote style="border-color:currentcolor currentcolor currentcolor rgb(204,204,204);border-style:none none none solid;border-width:medium medium medium 1pt;padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">Ok, I am clear now.</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">I</span><span style="font-size:10.5pt;font-family:DengXian">’<span lang="EN-US">ve added ssl_free in socket reset
and socket finish function, though glusterfsd memory leak is not that much, still it is leaking, from source code I can not find anything else,</span></span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">Could you help to check if this issue exists in your env? If not I may have a try to merge your patch .</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">Step</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="gmail-m_-1109814905353783812gmail-m3903278274190134145msolistparagraph" style="margin-left:18pt">
<span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">1></span><span style="font-size:7pt;font-family:"Times New Roman",serif" lang="EN-US">
</span><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">while true;do gluster v heal <vol-name> info,</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="gmail-m_-1109814905353783812gmail-m3903278274190134145msolistparagraph" style="margin-left:18pt">
<span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">2></span><span style="font-size:7pt;font-family:"Times New Roman",serif" lang="EN-US">
</span><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">check the vol-name glusterfsd memory usage, it is obviously increasing.</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US">cynthia</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:DengXian" lang="EN-US"> </span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11pt;font-family:"Calibri",sans-serif" lang="EN-US">From:</span></b><span style="font-size:11pt;font-family:"Calibri",sans-serif" lang="EN-US"> Milind
Changire <<a href="mailto:mchangir@redhat.com" target="_blank">mchangir@redhat.com</a>>
<br>
<b>Sent:</b> Monday, April 22, 2019 2:36 PM<br>
<b>To:</b> Zhou, Cynthia (NSB - CN/Hangzhou) <<a href="mailto:cynthia.zhou@nokia-sbell.com" target="_blank">cynthia.zhou@nokia-sbell.com</a>><br>
<b>Cc:</b> Atin Mukherjee <<a href="mailto:amukherj@redhat.com" target="_blank">amukherj@redhat.com</a>>;
<a href="mailto:gluster-devel@gluster.org" target="_blank">gluster-devel@gluster.org</a><br>
<b>Subject:</b> Re: [Gluster-devel] glusterfsd memory leak issue found after enable ssl</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p>
<div>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">According to BIO_new_socket() man page ...<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><b><span style="background:rgb(255,242,204) none repeat scroll 0% 0%" lang="EN-US">If the close flag is set then the socket is shut down and closed when the BIO is freed.</span></b><span lang="EN-US"><u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US">For Gluster to have more control over the socket shutdown, the BIO_NOCLOSE flag is set. Otherwise, SSL takes control of socket shutdown whenever BIO is freed.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span lang="EN-US"> <u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US">_______________________________________________<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@gluster.org" target="_blank">Gluster-devel@gluster.org</a><br>
<a href="https://lists.gluster.org/mailman/listinfo/gluster-devel" target="_blank">https://lists.gluster.org/mailman/listinfo/gluster-devel</a><u></u><u></u></span></p>
</blockquote>
</div>
<p class="MsoNormal"><span lang="EN-US"><br clear="all">
<u></u><u></u></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
<p class="MsoNormal"><span lang="EN-US">-- <u></u><u></u></span></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">Amar Tumballi (amarts)<u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br>
<br>
Community Meeting Calendar:<br>
<br>
APAC Schedule -<br>
Every 2nd and 4th Tuesday at 11:30 AM IST<br>
Bridge: <a href="https://bluejeans.com/836554017" rel="noreferrer" target="_blank">https://bluejeans.com/836554017</a><br>
<br>
NA/EMEA Schedule -<br>
Every 1st and 3rd Tuesday at 01:00 PM EDT<br>
Bridge: <a href="https://bluejeans.com/486278655" rel="noreferrer" target="_blank">https://bluejeans.com/486278655</a><br>
<br>
Gluster-devel mailing list<br>
<a href="mailto:Gluster-devel@gluster.org" target="_blank">Gluster-devel@gluster.org</a><br>
<a href="https://lists.gluster.org/mailman/listinfo/gluster-devel" rel="noreferrer" target="_blank">https://lists.gluster.org/mailman/listinfo/gluster-devel</a><br>
<br>
</blockquote></div></div>