Boost logo

Boost :

Subject: [boost] invalid access to stack memory?
From: alexc (alexc_at_[hidden])
Date: 2017-02-11 07:47:50


Hi all,

followed detail of the case, an object constructor store this pointer to a static variable. could it be a problem?

detail/call_stack.hpp
explicit context(Key* k)
   : key_(k),
    next_(call_stackKey, Value::top_)
  {
   value_ = reinterpret_castunsigned char*(this);
   call_stackKey, Value::top_ = this; // == store this to a static variable
  }

detail/impl/strand_service.ipp
void strand_service::do_complete(io_service_impl* owner, operation* base,
  const boost::system::error_code ec, std::size_t /*bytes_transferred*/)
{
 if (owner)
 {
  strand_impl* impl = static_caststrand_impl*(base);

  // Indicate that this strand is executing on the current thread.
  call_stackstrand_impl::context ctx(impl); // == local variable ctx, its this pointer will be stroed in a static variable.

Regards,
Alex


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk