Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ corruption of the heap
    primarykey
    data
    text
    <p>I have a simple synchronisedQueue</p> <pre><code> template &lt;typename T&gt; class SynchronisedQueue { public: void Enqueue(const T&amp; data) { boost::unique_lock&lt;boost::mutex&gt; lock(queueMutex); dataQueue.push(data); conditionVariable.notify_one(); } T Dequeue() { boost::unique_lock&lt;boost::mutex&gt; lock(queueMutex); while (dataQueue.size()==0) { conditionVariable.wait(lock); } T result=dataQueue.front(); dataQueue.pop(); return result; } private: std::queue&lt;T&gt; dataQueue; // Use STL queue to store data boost::mutex queueMutex; // The mutex to synchronise on boost::condition_variable conditionVariable; // The condition to wait for }; </code></pre> <p>When I Dequeue from queue, I sometimes get corruption of the heap....</p> <blockquote> <p>HEAP: Free Heap block ccb1080 modified at ccb13c0 after it was freed</p> </blockquote> <p>call stack is :</p> <pre><code>ntdll.dll!76fa5654() [Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll] ntdll.dll!76f6a554() ntdll.dll!76f35a70() ntdll.dll!76fa5eff() ntdll.dll!76f6a3ba() ntdll.dll!76f35a70() msvcr90d.dll!_heap_alloc_base(unsigned int size=1222) Line 105 + 0x28 bytes C msvcr90d.dll!_heap_alloc_dbg_impl(unsigned int nSize=1186, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x1310ee18) Line 427 + 0x9 bytes C++ msvcr90d.dll!_nh_malloc_dbg_impl(unsigned int nSize=1186, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0, int * errno_tmp=0x1310ee18) Line 239 + 0x19 bytes C++ msvcr90d.dll!_nh_malloc_dbg(unsigned int nSize=1186, int nhFlag=0, int nBlockUse=1, const char * szFileName=0x00000000, int nLine=0) Line 296 + 0x1d bytes C++ msvcr90d.dll!malloc(unsigned int nSize=1186) Line 56 + 0x15 bytes C++ msvcr90d.dll!operator new(unsigned int size=1186) Line 59 + 0x9 bytes C++ x.ax!std::_Allocate&lt;unsigned char&gt;(unsigned int _Count=1186, unsigned char * __formal=0x00000000) Line 43 + 0x9 bytes C++ ax.ax!std::allocator&lt;unsigned char&gt;::allocate(unsigned int _Count=1186) Line 145 + 0xb bytes C++ ax.ax!std::vector&lt;unsigned char,std::allocator&lt;unsigned char&gt; &gt;::_Buy(unsigned int _Capacity=1186) Line 1110 + 0xf bytes C++ ax.ax!std::vector&lt;unsigned char,std::allocator&lt;unsigned char&gt; &gt;::vector&lt;unsigned char,std::allocator&lt;unsigned char&gt; &gt;(const std::vector&lt;unsigned char,std::allocator&lt;unsigned char&gt; &gt; &amp; _Right=[1186](83 'S',50 '2',54 '6',67 'C',162 '¢',4 '',0,0,108 'l',0,0,0,2 '',64 '@',0,0,6 '',14 '',64 '@',0,35 '#',2 '',147 '“',76 'L',114 'r',53 '5',0,0,54 '6',79 'O',78 'N',4 '',0,0,0,0,54 '6',79 'O',78 'N',4 '',0,0,0,0,255 'ÿ',255 'ÿ',255 'ÿ',255 'ÿ',255 'ÿ',255 'ÿ',255 'ÿ',255 'ÿ',106 'j',4 '',0,0,0,0,0,1 '',65 'A',154 'š',3 '',1 '',176 '°',159 'Ÿ',255 'ÿ',240 'ğ',199 'Ç',...)) Line 501 + 0x11 bytes C++ ax.ax!SynchronisedQueue&lt;std::vector&lt;unsigned char,std::allocator&lt;unsigned char&gt; &gt; &gt;::Dequeue() Line 32 + 0xc bytes C++ ax.ax!PPin::FillBuffer(IMediaSample * pSample=0x0cadbea8) Line 225 + 0x12 bytes C++ ax.ax!PPin::DoBufferProcessingLoop() Line 300 + 0x13 bytes C++ ax.ax!CSourceStream::ThreadProc() + 0x13e bytes ax.ax!CAMThread::InitialThreadProc() + 0x51 bytes kernel32.dll!753bed6c() ntdll.dll!76f4377b() ntdll.dll!76f4374e() </code></pre> <blockquote> <p>What may cause this heap corruption? How to debug heap corruption errors? Any ideas...</p> </blockquote> <p><strong>UPDATE:</strong> Usage sample</p> <pre><code>// Enqueue void GetVideoStreams( BYTE *pData) { std::vector&lt;BYTE&gt; vecFrame(pData, pData + nLen/sizeof(pData[0])); IncomingFramesQueue.Enqueue(vecFrame); } //Dequeue void ConsumeVideoStreams() { vector&lt;BYTE&gt; data = IncomingFramesQueue.Dequeue(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload