Opened 13 years ago

Closed 13 years ago

#3273 closed Bugs (duplicate)

Boost::sherad_ptr crash when used in stl queue

Reported by: vikash.sharma@… Owned by: René Rivera
Milestone: Boost 1.40.0 Component: smart_ptr
Version: Boost 1.37.0 Severity: Regression
Keywords: Boost::shared_ptr crash Cc: koushik.das@…

Description

Hi, We have a scenario where we are storing instances of boost::shared_ptr in a stl queue. Then we pop the data out of Queue and do further processing. If i am correct then the pop() provided by stl queue calls the destructor of the object being popped out(which in this case would be boost::shared_ptr instance). This happens in a continuous daemon process which crashes at some random point say after 6 or 8 hrs because of boost pointer corruption. Am provding a small template below as per our implementation.

boost::shared_ptr<Sample> spSample; spSample.reset(new Sample()) ;

queue.push(spSample) ;

The below processing happens in a thread. No object is being shared between threads. Each thread has its own stl queue into which the data is pumped in by parent thread as shown above. boost::shared_ptr<Sample> spSample1 = q.front() ; q.pop() ; Will call the destructor of the shared_ptr at q.front()

some function called which takes spSample1 as paramater func(spSample1) ;

Is it safe to use boost::shared_ptr with stl queue ??

We are using version 1.33.1.

Change History (1)

comment:1 by Steven Watanabe, 13 years ago

Component: Regression Testingsmart_ptr
Resolution: duplicate
Status: newclosed

Duplicates #3272.

Note: See TracTickets for help on using tickets.