Opened 7 years ago

Last modified 7 years ago

#11794 new Bugs

SSL context and/or stream valgrind reports conflicting access in libcrypto.so

Reported by: Aleksey Barsuk <barsuk.alexey@…> Owned by: chris_kohlhoff
Milestone: To Be Determined Component: asio
Version: Boost 1.58.0 Severity: Problem
Keywords: Cc:

Description

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

Attachments (2)

boost_ssl_test.tgz (4.0 KB ) - added by Aleksey Barsuk <barsuk.alexey@…> 7 years ago.
test suite
drd.xml (57.0 KB ) - added by Aleksey Barsuk <barsuk.alexey@…> 7 years ago.
valgrind output

Download all attachments as: .zip

Change History (5)

by Aleksey Barsuk <barsuk.alexey@…>, 7 years ago

Attachment: boost_ssl_test.tgz added

test suite

by Aleksey Barsuk <barsuk.alexey@…>, 7 years ago

Attachment: drd.xml added

valgrind output

comment:1 by Aleksey Barsuk <barsuk.alexey@…>, 7 years ago

Summary: SSL context and/or stream valgrind confliction accessSSL context and/or stream valgrind reports conflicting access in libcrypto.so

comment:2 by Aleksey Barsuk <barsuk.alexey@…>, 7 years ago

Version: Boost 1.57.0Boost 1.58.0

comment:3 by viboes, 7 years ago

Component: Noneasio
Owner: set to chris_kohlhoff
Note: See TracTickets for help on using tickets.