You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by Isuru Haththotuwa <is...@gmail.com> on 2012/11/04 13:05:56 UTC

Exception in SSL_read: Wrong Version Number

Hi all,

I'm in the process of learning thrift. I wrote a secure client in C++ to
connect to a thrift server, authenticated via SSL. First I wrote a single
threaded application, which ran without any issues. But, when I try to send
requests to the server concurrently with multiple threads, the program
fails with the following exception:

*
terminate called after throwing an instance of
'apache::thrift::transport::TSSLException'
  what():  SSL_read: wrong version number
terminate called recursively*


Kindly let me know what is the issue here, and how should I avoid it.

-- 
Thanks and Regards,
Isuru

Re: Exception in SSL_read: Wrong Version Number

Posted by Isuru Haththotuwa <is...@gmail.com>.
In Further analysis, this happens through the flush() method in
TBufferedTransport.  However, if I use only the main thread, or another
single thread apart from the main thread, this issue does not occur. It
seems the flush() method is not thread safe. Any thought on this and a
possible workaround for the issue?

Thanks.

On Tue, Nov 6, 2012 at 10:21 AM, Isuru Haththotuwa <is...@gmail.com>wrote:

> Hi Roger,
>
> Thanks for the reply. I do not have a simple test case as such since this
> code communicates with a server which is not written by me. I can give you
> a simple sample of the client code that I wrote if it is of any help.
> Meanwhile, using gdb, I got this stacktrace from the core dump:
>
>
> #0  0x00007ffff7088445 in __GI_raise (sig=<optimized out>) at
> ../nptl/sysdeps/unix/sysv/linux/raise.c:64
> #1  0x00007ffff708bbab in __GI_abort () at abort.c:91
> #2  0x00007ffff76de675 in __gnu_cxx::__verbose_terminate_handler() () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #3  0x00007ffff76dc846 in ?? () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #4  0x00007ffff76dc873 in std::terminate() () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #5  0x00007ffff76dc96e in __cxa_throw () from
> /usr/lib/x86_64-linux-gnu/libstdc++.so.6
> #6  0x00007ffff7ba6145 in apache::thrift::transport::TSSLSocket::read
> (this=<optimized out>, buf=<optimized out>, len=512) at
> src/transport/TSSLSocket.cpp:177
> #7  0x00007ffff7babdf1 in read (len=<optimized out>, buf=<optimized out>,
> this=<optimized out>) at ./src/transport/TTransport.h:109
> #8  apache::thrift::transport::TBufferedTransport::readSlow
> (this=0x667e20, buf=0x7ffff4ef0ab0 "", len=4) at
> src/transport/TBufferTransports.cpp:52
> #9  0x0000000000409a7d in apache::thrift::transport::TBufferBase::read
> (this=0x667e20, buf=0x7ffff4ef0ab0 "", len=4)
>     at /usr/local/include/thrift/transport/TBufferTransports.h:69
> #10 0x000000000040ca53 in
> apache::thrift::transport::readAll<apache::thrift::transport::TBufferBase>
> (trans=..., buf=0x7ffff4ef0ab0 "", len=4)
>     at /usr/local/include/thrift/transport/TTransport.h:39
> #11 0x0000000000409afd in apache::thrift::transport::TBufferBase::readAll
> (this=0x667e20, buf=0x7ffff4ef0ab0 "", len=4)
>     at /usr/local/include/thrift/transport/TBufferTransports.h:82
> #12 0x000000000040a09d in
> apache::thrift::transport::TBufferedTransport::readAll (this=0x667e20,
> buf=0x7ffff4ef0ab0 "", len=4)
>     at /usr/local/include/thrift/transport/TBufferTransports.h:279
> #13 0x000000000041350f in
> apache::thrift::transport::TVirtualTransport<apache::thrift::transport::TBufferedTransport,
> apache::thrift::transport::TBufferBase>::readAll_virt (this=0x667e20,
> buf=0x7ffff4ef0ab0 "", len=4) at
> /usr/local/include/thrift/transport/TVirtualTransport.h:99
> ---Type <return> to continue, or q <return> to quit---
> #14 0x0000000000408ac1 in apache::thrift::transport::TTransport::readAll
> (this=0x667e20, buf=0x7ffff4ef0ab0 "", len=4)
>     at /usr/local/include/thrift/transport/TTransport.h:126
> #15 0x0000000000414381 in
> apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::readI32
> (this=0x6682c0,
>     i32=@0x7ffff4ef0b10: 6720064) at
> /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:372
> #16 0x0000000000413ba9 in
> apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::readMessageBegin
> (this=0x6682c0, name=...,
>     messageType=@0x7ffff4ef0c5c: 32767, seqid=@0x7ffff4ef0c58: 0) at
> /usr/local/include/thrift/protocol/TBinaryProtocol.tcc:203
> #17 0x00000000004131b0 in
> apache::thrift::protocol::TVirtualProtocol<apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>,
> apache::thrift::protocol::TProtocolDefaults>::readMessageBegin_virt
> (this=0x6682c0, name=..., messageType=@0x7ffff4ef0c5c: 32767,
> seqid=@0x7ffff4ef0c58: 0)
>     at /usr/local/include/thrift/protocol/TVirtualProtocol.h:432
> #18 0x000000000041be7a in
> apache::thrift::protocol::TProtocol::readMessageBegin (this=0x6682c0,
> name=..., messageType=@0x7ffff4ef0c5c: 32767,
>     seqid=@0x7ffff4ef0c58: 0) at
> /usr/local/include/thrift/protocol/TProtocol.h:526
> *#19 0x00000000004189ef in
> ThriftSecureEventTransmissionServiceClient::recv_publish() ()
> #20 0x0000000000418805 in
> ThriftSecureEventTransmissionServiceClient::publish(ThriftEventBundle
> const&) ()
> #21 0x0000000000407918 in testPublish (test=0x64bf30) at
> bam_publisher.cpp:125*
> #22 0x0000000000414577 in boost::_bi::list1<boost::_bi::value<Test*>
> >::operator()<void (*)(Test*), boost::_bi::list0> (this=0x67c0a0,
>     f=@0x67c098: 0x407774 <testPublish(Test*)>, a=...) at
> /usr/include/boost/bind/bind.hpp:253
> #23 0x000000000041369b in boost::_bi::bind_t<void, void (*)(Test*),
> boost::_bi::list1<boost::_bi::value<Test*> > >::operator() (this=0x67c098)
>     at /usr/include/boost/bind/bind_template.hpp:20
> #24 0x0000000000412acc in
> boost::detail::thread_data<boost::_bi::bind_t<void, void (*)(Test*),
> boost::_bi::list1<boost::_bi::value<Test*> > > >::run (
> ---Type <return> to continue, or q <return> to quit---
>     this=0x67bf10) at /usr/include/boost/thread/detail/thread.hpp:61
> #25 0x00007ffff7933ce9 in thread_proxy () from
> /usr/lib/libboost_thread.so.1.46.1
> #26 0x00007ffff6e3ce9a in start_thread (arg=0x7ffff4ef1700) at
> pthread_create.c:308
> #27 0x00007ffff7145dbd in clone () at
> ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
> #28 0x0000000000000000 in ?? ()
>
>
> I have highlighted the sections that are showing the files I have
> generated and written in my side. Any help on this is greatly appreciated!
>
> Thank you.
>
>
>
> On Tue, Nov 6, 2012 at 2:47 AM, Roger Meier <ro...@bufferoverflow.ch>wrote:
>
>> I've no idea for the moment...
>>
>> Do you have a test case to reproduce it?
>> e.g. within cross language test suite started via test/test.sh
>>
>> -roger
>>
>> > -----Ursprüngliche Nachricht-----
>> > Von: Isuru Haththotuwa [mailto:isurulucky@gmail.com]
>> > Gesendet: Sonntag, 4. November 2012 13:06
>> > An: dev@thrift.apache.org
>> > Betreff: Exception in SSL_read: Wrong Version Number
>> >
>> > Hi all,
>> >
>> > I'm in the process of learning thrift. I wrote a secure client in C++
>> to connect
>> > to a thrift server, authenticated via SSL. First I wrote a single
>> threaded
>> > application, which ran without any issues. But, when I try to send
>> requests to
>> > the server concurrently with multiple threads, the program fails with
>> the
>> > following exception:
>> >
>> > *
>> > terminate called after throwing an instance of
>> > 'apache::thrift::transport::TSSLException'
>> >   what():  SSL_read: wrong version number terminate called recursively*
>> >
>> >
>> > Kindly let me know what is the issue here, and how should I avoid it.
>> >
>> > --
>> > Thanks and Regards,
>> > Isuru
>>
>>
>
>
> --
> Thanks and Regards,
> Isuru
>
>


-- 
Thanks and Regards,
Isuru

Re: Exception in SSL_read: Wrong Version Number

Posted by Isuru Haththotuwa <is...@gmail.com>.
Hi Roger,

Thanks for the reply. I do not have a simple test case as such since this
code communicates with a server which is not written by me. I can give you
a simple sample of the client code that I wrote if it is of any help.
Meanwhile, using gdb, I got this stacktrace from the core dump:


#0  0x00007ffff7088445 in __GI_raise (sig=<optimized out>) at
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff708bbab in __GI_abort () at abort.c:91
#2  0x00007ffff76de675 in __gnu_cxx::__verbose_terminate_handler() () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff76dc846 in ?? () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff76dc873 in std::terminate() () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff76dc96e in __cxa_throw () from
/usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff7ba6145 in apache::thrift::transport::TSSLSocket::read
(this=<optimized out>, buf=<optimized out>, len=512) at
src/transport/TSSLSocket.cpp:177
#7  0x00007ffff7babdf1 in read (len=<optimized out>, buf=<optimized out>,
this=<optimized out>) at ./src/transport/TTransport.h:109
#8  apache::thrift::transport::TBufferedTransport::readSlow (this=0x667e20,
buf=0x7ffff4ef0ab0 "", len=4) at src/transport/TBufferTransports.cpp:52
#9  0x0000000000409a7d in apache::thrift::transport::TBufferBase::read
(this=0x667e20, buf=0x7ffff4ef0ab0 "", len=4)
    at /usr/local/include/thrift/transport/TBufferTransports.h:69
#10 0x000000000040ca53 in
apache::thrift::transport::readAll<apache::thrift::transport::TBufferBase>
(trans=..., buf=0x7ffff4ef0ab0 "", len=4)
    at /usr/local/include/thrift/transport/TTransport.h:39
#11 0x0000000000409afd in apache::thrift::transport::TBufferBase::readAll
(this=0x667e20, buf=0x7ffff4ef0ab0 "", len=4)
    at /usr/local/include/thrift/transport/TBufferTransports.h:82
#12 0x000000000040a09d in
apache::thrift::transport::TBufferedTransport::readAll (this=0x667e20,
buf=0x7ffff4ef0ab0 "", len=4)
    at /usr/local/include/thrift/transport/TBufferTransports.h:279
#13 0x000000000041350f in
apache::thrift::transport::TVirtualTransport<apache::thrift::transport::TBufferedTransport,
apache::thrift::transport::TBufferBase>::readAll_virt (this=0x667e20,
buf=0x7ffff4ef0ab0 "", len=4) at
/usr/local/include/thrift/transport/TVirtualTransport.h:99
---Type <return> to continue, or q <return> to quit---
#14 0x0000000000408ac1 in apache::thrift::transport::TTransport::readAll
(this=0x667e20, buf=0x7ffff4ef0ab0 "", len=4)
    at /usr/local/include/thrift/transport/TTransport.h:126
#15 0x0000000000414381 in
apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::readI32
(this=0x6682c0,
    i32=@0x7ffff4ef0b10: 6720064) at
/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:372
#16 0x0000000000413ba9 in
apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>::readMessageBegin
(this=0x6682c0, name=...,
    messageType=@0x7ffff4ef0c5c: 32767, seqid=@0x7ffff4ef0c58: 0) at
/usr/local/include/thrift/protocol/TBinaryProtocol.tcc:203
#17 0x00000000004131b0 in
apache::thrift::protocol::TVirtualProtocol<apache::thrift::protocol::TBinaryProtocolT<apache::thrift::transport::TTransport>,
apache::thrift::protocol::TProtocolDefaults>::readMessageBegin_virt
(this=0x6682c0, name=..., messageType=@0x7ffff4ef0c5c: 32767,
seqid=@0x7ffff4ef0c58: 0)
    at /usr/local/include/thrift/protocol/TVirtualProtocol.h:432
#18 0x000000000041be7a in
apache::thrift::protocol::TProtocol::readMessageBegin (this=0x6682c0,
name=..., messageType=@0x7ffff4ef0c5c: 32767,
    seqid=@0x7ffff4ef0c58: 0) at
/usr/local/include/thrift/protocol/TProtocol.h:526
*#19 0x00000000004189ef in
ThriftSecureEventTransmissionServiceClient::recv_publish() ()
#20 0x0000000000418805 in
ThriftSecureEventTransmissionServiceClient::publish(ThriftEventBundle
const&) ()
#21 0x0000000000407918 in testPublish (test=0x64bf30) at
bam_publisher.cpp:125*
#22 0x0000000000414577 in boost::_bi::list1<boost::_bi::value<Test*>
>::operator()<void (*)(Test*), boost::_bi::list0> (this=0x67c0a0,
    f=@0x67c098: 0x407774 <testPublish(Test*)>, a=...) at
/usr/include/boost/bind/bind.hpp:253
#23 0x000000000041369b in boost::_bi::bind_t<void, void (*)(Test*),
boost::_bi::list1<boost::_bi::value<Test*> > >::operator() (this=0x67c098)
    at /usr/include/boost/bind/bind_template.hpp:20
#24 0x0000000000412acc in
boost::detail::thread_data<boost::_bi::bind_t<void, void (*)(Test*),
boost::_bi::list1<boost::_bi::value<Test*> > > >::run (
---Type <return> to continue, or q <return> to quit---
    this=0x67bf10) at /usr/include/boost/thread/detail/thread.hpp:61
#25 0x00007ffff7933ce9 in thread_proxy () from
/usr/lib/libboost_thread.so.1.46.1
#26 0x00007ffff6e3ce9a in start_thread (arg=0x7ffff4ef1700) at
pthread_create.c:308
#27 0x00007ffff7145dbd in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#28 0x0000000000000000 in ?? ()


I have highlighted the sections that are showing the files I have generated
and written in my side. Any help on this is greatly appreciated!

Thank you.


On Tue, Nov 6, 2012 at 2:47 AM, Roger Meier <ro...@bufferoverflow.ch> wrote:

> I've no idea for the moment...
>
> Do you have a test case to reproduce it?
> e.g. within cross language test suite started via test/test.sh
>
> -roger
>
> > -----Ursprüngliche Nachricht-----
> > Von: Isuru Haththotuwa [mailto:isurulucky@gmail.com]
> > Gesendet: Sonntag, 4. November 2012 13:06
> > An: dev@thrift.apache.org
> > Betreff: Exception in SSL_read: Wrong Version Number
> >
> > Hi all,
> >
> > I'm in the process of learning thrift. I wrote a secure client in C++ to
> connect
> > to a thrift server, authenticated via SSL. First I wrote a single
> threaded
> > application, which ran without any issues. But, when I try to send
> requests to
> > the server concurrently with multiple threads, the program fails with the
> > following exception:
> >
> > *
> > terminate called after throwing an instance of
> > 'apache::thrift::transport::TSSLException'
> >   what():  SSL_read: wrong version number terminate called recursively*
> >
> >
> > Kindly let me know what is the issue here, and how should I avoid it.
> >
> > --
> > Thanks and Regards,
> > Isuru
>
>


-- 
Thanks and Regards,
Isuru

AW: Exception in SSL_read: Wrong Version Number

Posted by Roger Meier <ro...@bufferoverflow.ch>.
I've no idea for the moment...

Do you have a test case to reproduce it?
e.g. within cross language test suite started via test/test.sh

-roger

> -----Ursprüngliche Nachricht-----
> Von: Isuru Haththotuwa [mailto:isurulucky@gmail.com]
> Gesendet: Sonntag, 4. November 2012 13:06
> An: dev@thrift.apache.org
> Betreff: Exception in SSL_read: Wrong Version Number
> 
> Hi all,
> 
> I'm in the process of learning thrift. I wrote a secure client in C++ to connect
> to a thrift server, authenticated via SSL. First I wrote a single threaded
> application, which ran without any issues. But, when I try to send requests to
> the server concurrently with multiple threads, the program fails with the
> following exception:
> 
> *
> terminate called after throwing an instance of
> 'apache::thrift::transport::TSSLException'
>   what():  SSL_read: wrong version number terminate called recursively*
> 
> 
> Kindly let me know what is the issue here, and how should I avoid it.
> 
> --
> Thanks and Regards,
> Isuru