[Boost-bugs] [Boost C++ Libraries] #11794: SSL context and/or stream valgrind confliction access

Subject: [Boost-bugs] [Boost C++ Libraries] #11794: SSL context and/or stream valgrind confliction access
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-11-13 10:03:42


#11794: SSL context and/or stream valgrind confliction access
----------------------------------------------+----------------------------
 Reporter: Aleksey Barsuk <barsuk.alexey@…> | Type: Bugs
   Status: new | Milestone: To Be
Component: None | Determined
 Severity: Problem | Version: Boost 1.57.0
                                              | Keywords:
----------------------------------------------+----------------------------
 Creating SSL context and/or stream simultaneously from diferent threads,
 using io_service that has deferred handlers, or already running, makes
 valgrind drd tool reporting conflicting accesses in lybcrypto.so

 {{{
 #include <string>
 #include <iostream>
 #include <boost/asio.hpp>
 #include <boost/thread.hpp>
 #include <boost/asio/ssl.hpp>
 #include "openssl/opensslconf.h"
 #include <stdio.h>
 #include <pthread.h>
 #include "openssl/err.h"


 typedef boost::asio::ip::tcp::socket TSocket;
 typedef boost::asio::ssl::stream<TSocket> TSSLSocket;
 typedef boost::asio::ssl::context TSSLContext;
 typedef boost::asio::io_service TService;
 typedef boost::asio::io_service::work TWork;


 int main()
 {
   const unsigned int threads_count=10;

   //Info
   std::cout<<"Open SSL library version="<<OPENSSL_VERSION_TEXT<<std::endl;
 #ifdef OPENSSL_THREADS
   std::cout<<"OpenSSL threads enabled"<<std::endl;
 #else
   std::cout<<"OpenSSL threads disabled"<<std::endl;
 #endif


    //Creating sockets simultaneously in diferent threads
   auto create_ssl_socket=[&]
     {

       TService service;

       //boost::asio::ioservice::work makes bug appear
       TWork work(service);

       TSSLContext context(boost::asio::ssl::context::tlsv1_client);
       TSSLSocket ssl_socket(service,context);
       service.run();
     };


   for (unsigned i=0; i<=threads_count;i++)
     {
       boost::thread t(create_ssl_socket);
       t.detach();
     }



   do {
     std::cout<<"Press enter to quit..."<<std::endl;
   }

   while (std::cin.get()==0);
   return 0;
 }

 }}}

 {{{
 valgrind --tool=drd --gen-suppressions=all --first-race-only=yes --read-
 var-info=yes --num-callers=100 --xml=yes --xml-file=drd.xml
 ./executale_name
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/11794>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC