Advertisement
Guest User

Untitled

a guest
Jul 5th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. // We are using boost 1_67_0
  2.  
  3. // We have this code:
  4. auto channel = boost::make_shared<Channel>(host, port, user, pass, vhost, 131072);
  5.  
  6. // And it crashes at run-time in make_shared. The crash occurs here:
  7.  
  8. template< class T, class... Args > typename boost::detail::sp_if_not_array< T >::type make_shared( Args && ... args )
  9. {
  10.     boost::shared_ptr< T > pt( static_cast< T* >( 0 ), BOOST_SP_MSD( T ) );
  11.     boost::detail::sp_ms_deleter< T > * pd = static_cast<boost::detail::sp_ms_deleter< T > *>( pt._internal_get_untyped_deleter() );
  12.     void * pv = pd->address();
  13.     ::new( pv ) T( boost::detail::sp_forward<Args>( args )... );
  14.     pd->set_initialized(); //   <---------------------------------- HERE
  15.     T * pt2 = static_cast< T* >( pv );
  16.     boost::detail::sp_enable_shared_from_this( &pt, pt2, pt2 );
  17.     return boost::shared_ptr< T >( pt, pt2 );
  18. }
  19.  
  20. //The declaration of Channel can be found here:
  21. https://github.com/alanxz/SimpleAmqpClient/blob/master/src/SimpleAmqpClient/Channel.h
  22.  
  23. //The definition is here:
  24. https://github.com/alanxz/SimpleAmqpClient/blob/master/src/Channel.cpp
  25.  
  26. // We also tried making our own dummy struct to se if we could reproduce the crash, but it runs fine:
  27.     struct lolbob {
  28.         std::string host;
  29.         int port;
  30.         std::string user;
  31.         std::string pass;
  32.         std::string vhost;
  33.  
  34.         explicit lolbob(const std::string &host,int port, const std::string &user, const std::string &pass, const std::string &vhost)
  35.             : host(host)
  36.             , port(port)
  37.             , user(user)
  38.             , pass(pass)
  39.             , vhost(vhost)
  40.         {
  41.             std::cout << "lolbob ctor host=" << host << ", user=" << user << ", pass=" << pass << ", virtualhost=" << vhost << endl;
  42.         }
  43.     };
  44.  
  45.     auto bahn=boost::make_shared<lolbob>(host, port, user, pass, vhost );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement