Quantcast

invalid access to stack memory?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

invalid access to stack memory?

Boost - Dev mailing list
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

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invalid access to stack memory?

Boost - Dev mailing list
On 02/11/2017 08:47 AM, alexc via Boost wrote:

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

 From a quick look at the code, I do not think that it poses a problem.

The idea, as I understand it, is to use RAII to push and pop a "stack
frame" (call_stack<T>::context) onto a thread-local static "stack"
(call_stack<T>::top_.) The context destructor will remove itself from
the "stack".


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: invalid access to stack memory?

Boost - Dev mailing list
In reply to this post by Boost - Dev mailing list
Original Message
Sender:Bjorn Reese via [hidden email]
Recipient:[hidden email]
Cc:Bjorn [hidden email]
Date:Saturday, Feb 11, 2017 19:39
Subject:Re: [boost] invalid access to stack memory?


On 02/11/2017 08:47 AM, alexc via Boost wrote:
 followed detail of the case, an object constructor store this pointer to a static variable. could it be a problem?
From a quick look at the code, I do not think that it poses a problem.
The idea, as I understand it, is to use RAII to push and pop a "stack
frame" (call_stackT::context) onto a thread-local static "stack"
(call_stackT::top_.) The context destructor will remove itself from
the "stack".
Oh, context class “recover” thecall_stackT::top_ indestructor, I miss this in the first place,
thank you, Bjorn, it’s a very cool idea to me.
_______________________________________________ Unsubscribe  other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Loading...