Advertisement

About CContextMgr bug Report

Started by September 04, 2009 09:07 PM
2 comments, last by WitchLord 15 years, 2 months ago
Hi All I found a sommthing! 'CContextMgr' has a bug~ Do you remamber the 'samples\coroutine' ! It's work ! BUT two script module is running in the sample code! It's Exterimated when one script module exit ~! so I fix it up ! like this!!!!!!!!!!!!! void CContextMgr::ExecuteScripts() { g_ctxMgr = this; ....... ...... // Check if the system time is higher than the time set for the contexts asUINT time = getTimeFunc ? getTimeFunc() : asUINT(-1); for( currentThread = 0; currentThread < threads.size(); urrentThread++ ) { //ADD THIS CODE! if( threads[currentThread]->coRoutines.size()==0) continue; ..... ...... } g_ctxMgr = 0; } asIScriptContext *CContextMgr::AddContextForCoRoutine(asIScriptContext *currCtx, int funcId) { ..... ..... // TODO: Start with the current thread so that we can find the group faster for( asUINT n = 0; n < threads.size(); n++ ) { //ADD THIS CODE! if( threads[n]->coRoutines.size()==0) continue; ...... ...... } return coctx; } void CContextMgr::SetSleeping(asIScriptContext *ctx, asUINT milliSeconds) { .... .... // TODO: Start with the current thread for( asUINT n = 0; n < threads.size(); n++ ) { //ADD THIS CODE! if( threads[n]->coRoutines.size()==0) continue; ..... ..... } } you only 3 line add the code !! I's will be success , work!! p.s) the letter has a bad english form...... T.T(I'm so sad!) I,m sorry! becouse my mother language is not English! so I gess, you may be don't understand the letter ,perfactly.
why it's a bug??

if 'threads[..]->coRoutines'
has no entry! (size is 0..)
then
'threads[..]->coRoutines[0]' will be have a trubble!!!

'Access violate~~~~' for OS Memoey manager~~


Advertisement
Thanks for the bug report, and the suggested fix. I'll look into this and check in the fix as soon as possible.

Don't worry about your english. I understood you perfectly.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I've checked in the fixes for this bug now. You can get it from the SVN (revision 480).

I went a bit further than just checking if the coRoutines array was empty. Instead I now remove the thread when no more contexts are executing in it. I also added pooling of the thread info structure so that there are little less memory allocations now.

I'll also add pooling of the asIScriptContext pointers in the future which will bring down the number of allocations even further.

Thanks,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement