Hi all, I have a C++ client which uses thrift to publish data to a remote server. When the remote server shut down, I catch an exception to see if I can re-connect to it periodically. However, in deallocating memory before re-initializing a client again, the client code always crashes. I debugged the issue and got the following stack trace:
(gdb) backtrace #0 0x00007ffff713891d in write () at ../sysdeps/unix/syscall-template.S:82 #1 0x00007ffff68e4c95 in ?? () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 #2 0x00007ffff68e2ae7 in BIO_write () from /lib/x86_64-linux-gnu/libcrypto.so.1.0.0 #3 0x00007ffff6bf9a50 in ?? () from /lib/x86_64-linux-gnu/libssl.so.1.0.0 #4 0x00007ffff6bfb483 in ?? () from /lib/x86_64-linux-gnu/libssl.so.1.0.0 #5 0x00007ffff6bf7b62 in ?? () from /lib/x86_64-linux-gnu/libssl.so.1.0.0 *#6 0x00007ffff7ba632a in apache::thrift::transport::TSSLSocket::close (this=0x67cc30) at src/transport/TSSLSocket.cpp:145 #7 0x00007ffff7ba647c in apache::thrift::transport::TSSLSocket::~TSSLSocket (this=0x67cc30, __in_chrg=<optimized out>) at src/transport/TSSLSocket.cpp:100 #8 0x00007ffff7ba6559 in apache::thrift::transport::TSSLSocket::~TSSLSocket (this=0x67cc30, __in_chrg=<optimized out>) at src/transport/TSSLSocket.cpp:101* #9 0x00007ffff7bace0a in release (this=0x6825c0) at /usr/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:145 #10 ~shared_count (this=0x682190, __in_chrg=<optimized out>) at /usr/include/boost/smart_ptr/detail/shared_count.hpp:217 #11 ~shared_ptr (this=0x682188, __in_chrg=<optimized out>) at /usr/include/boost/smart_ptr/shared_ptr.hpp:168 #12 ~TBufferedTransport (this=0x682160, __in_chrg=<optimized out>) at ./src/transport/TBufferTransports.h:191 #13 apache::thrift::transport::TBufferedTransport::~TBufferedTransport (this=0x682160, __in_chrg=<optimized out>) at ./src/transport/TBufferTransports.h:191 #14 0x000000000042d487 in boost::checked_delete<apache::thrift::transport::TBufferedTransport> (x=0x682160) at /usr/include/boost/checked_delete.hpp:34 #15 0x000000000042e1e4 in boost::detail::sp_counted_impl_p<apache::thrift::transport::TBufferedTransport>::dispose (this=0x67df80) at /usr/include/boost/smart_ptr/detail/sp_counted_impl.hpp:78 Please note that I have only added the relevant part of the stack trace. I have attached the complete one. In analyzing what is happening here, what I could grasp is that after the connection to the server is terminated, if socket::close method gets called the application crashes. Is this the expected behavior? Since this is happening implicitly because of the memory cleanup, how to handle this issue? -- Thanks and Regards, Isuru