hervea Posted September 8, 2016 Report Share Posted September 8, 2016 Hi, I am used to making containers with boost::shared_ptr<T> as a data type. I expected tlm_fifo to have similar semantics to STL containers, such as copy on push (tlm_fifo::put) But I am seeing a crash at end of sim when the tlm_fifo gets deleted with items still in it, and it looks like the structure under the tlm_fifo (circular_buffer) uses a placement new to allocate a new entry upon write(). This is bypassing the copy semantics of the shared_ptr and creating a wild pointer as a result. First, is this a known problem? If it is, is there another suitable container for shared_ptr? I basically need a queue with event notification and I'd rather not build my own deque with sc_event's Thank you Hervé Alexanian Xilinx, inc. Quote Link to comment Share on other sites More sharing options...
Philipp A Hartmann Posted September 21, 2016 Report Share Posted September 21, 2016 Which version of SystemC/TLM are you using? I'm afraid, there is a known issue in the 2.3.1 circular_buffer implementation. When the fifo is destroyed while there are still elements in it, the loop over the "to-be-cleared" items does not start at the right index. Instead, you need the following change: circular_buffer<T>::clear() { for( int i=0; i < used(); i++ ) { - buf_clear( m_buf, i ); + buf_clear( m_buf, (m_ri + i) % m_size ); } // ... In 2.3, there was another indexing bug related to resize, see http://forums.accellera.org/topic/1443-/. Hope that helps, Philipp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.