"list iterator not dereferencable"

"list iterator not dereferencable"


I've buit a small transcoder (in C++), not big deal, using Intel's filters mpeg2 decoder -> h264 encoder (from TS files). The SDK version is 1.5 Gold.
It works very nicely for quite some long time, but randomly, I keep getting this error (in Debug mode).

File: c:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\include\\list
Expression: list iterator not dereferencable

When I dump the stack frame, here is what I get (calling orderd is from bottom up):

msvcp90d.dll!_Debug_message(const wchar_t * message=0x0000000180067be0, const wchar_t *file=0x0000000180067310, unsigned int line=218) Line 24

h264_enc_filter.dll!std::list >::_Iterator<1>::operator->()
h264_enc_filter.dll!CBaseEncoder::DeliverNextFrame(void * pvParam=0x000000000046d770)
msvcr90d.dll!_callthreadstartex() Line 348 + 0x17 bytes
msvcr90d.dll!_threadstartex(void * ptd=0x000000000e448cd0) Line 331
kernel32.dll!BaseThreadInitThunk()+0xd bytes
ntdll.dll!RtlUserThreadStart()+0x21 bytes

I'm pretty sure, the problem is in the base_encoder.cpp, at:
if (!pEncoder->m_ResList.empty())
it = pEncoder->m_ResList.begin(); <- HERE SEEMS TO BE THE PROBLEM

sts = pEncoder->m_mfxVideoSession.SyncOperation(*it->psyncP, 0);

if ((MFX_ERR_NONE != sts && MFX_WRN_IN_EXECUTION != sts && MFX_ERR_MORE_DATA != sts)|| pEncoder->m_bStop)

I'm running Debug mode, x64 or x32, with or without using shared MFC dlls. All the system consists of nothing more than instantiating the Intel's filters, and launch the graph. All filters work in sync mode. Tried to remove the sync clock from each of them, but the problem still occurs. Like I've said, it works nicely for some time (sometimes minutes, sometimes hours) with correct h264 output, and then suddenly crashes.

Is there are a problem with the output management in the h264 encoder? The output port is hooked to a standard file writer filter

My PC configuration: Win7 Home Edition, x64, Intel Core Duo P8700 2.53GHz, ATI

Any help would be highly appreciated.

Thank you,

4 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Hi John,Seems that you've managed to catch a floating issue in sample encoder filter that we've recently discovered at our side as well. The reason is that 2 threads of sample encoder are using the same std::list m_ResList and std::list is not thread safe. We fixed that with critical sections and the fix will be available in the Media SDK 2.0 Beta, which will be out soon.Meanwhile you may try to apply the fix yourself as it is only sample code related. Below I'm pasting the corrected code, for the file base_encoder.cpp. Please let us know if this helps.Regards,NinamfxU32 _stdcall CBaseEncoder::DeliverNextFrame(void* pvParam){ mfxStatus sts = MFX_ERR_NONE; CBaseEncoder* pEncoder = reinterpret_cast (pvParam); std::list::iterator it; std::list::iterator jt; CHECK_POINTER(pEncoder, 1); for(;!pEncoder->m_bStop;) { // InputList will be empty in case session was joined for (jt = pEncoder->m_InputList.begin(); jt != pEncoder->m_InputList.end(); jt++) { if (!jt->pmfxSurface->Data.Locked) { EnterCriticalSection(&pEncoder->m_CriticalSection); SAFE_DELETE(jt->pmfxSurface); jt->pSample->Release(); pEncoder->m_InputList.erase(jt); LeaveCriticalSection(&pEncoder->m_CriticalSection); break; } } EnterCriticalSection(&pEncoder->m_CriticalSection); if (!pEncoder->m_ResList.empty()) { it = pEncoder->m_ResList.begin(); sts = pEncoder->m_mfxVideoSession.SyncOperation(*it->psyncP, 0); LeaveCriticalSection(&pEncoder->m_CriticalSection); if ((MFX_ERR_NONE != sts && MFX_WRN_IN_EXECUTION != sts && MFX_ERR_MORE_DATA != sts) || pEncoder->m_bStop) { pEncoder->m_pmfxENC->Close(); //need to free 1 element, to make next RunEncode possible, to get higher level know about error EnterCriticalSection(&pEncoder->m_CriticalSection); if (!pEncoder->m_InputList.empty()) { jt = pEncoder->m_InputList.begin(); SAFE_DELETE(jt->pmfxSurface); jt->pSample->Release(); pEncoder->m_InputList.erase(jt); } LeaveCriticalSection(&pEncoder->m_CriticalSection); pEncoder->m_bStop = true; return 1; } if (MFX_ERR_NONE == sts && it->pmfxBS->DataLength) { sts = pEncoder->m_pNotifier->OnFrameReady(it->pmfxBS); CHECK_RESULT(sts, MFX_ERR_NONE, 1); } if (MFX_ERR_NONE == sts || MFX_ERR_MORE_DATA == sts) { EnterCriticalSection(&pEncoder->m_CriticalSection); SAFE_DELETE(it->psyncP); SAFE_DELETE_ARRAY(it->pmfxBS->Data); SAFE_DELETE(it->pmfxBS); pEncoder->m_ResList.pop_front(); LeaveCriticalSection(&pEncoder->m_CriticalSection); } } else { LeaveCriticalSection(&pEncoder->m_CriticalSection); } if (MFX_WRN_IN_EXECUTION == sts || pEncoder->m_ResList.empty()) { MFX_THREAD_WAIT; } } return 0xedf;};

Hi Nina,

Apparently, this solved the problem, as it never occured since then.

Thank you for your support (you guys ar doing a great job with intel media sdk)


Hi John,Glad to hear that the problem got solved.Good luck!Nina

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi