I am quiet new to Angelscript and enjoyed it so far.
I face one serious problem at the moment which occurs with the following simple script:
class MyTest{ array<int> myList;}void main(){ MyTest example; while(true) { yield(); // this script suspends the script and checks for external input }}
At one of the yield calls I do the following to reset the context:
// abort the current module and discard it if(mEngine->GetModule("module")) { mContext->Abort(); mContext->Unprepare(); mEngine->DiscardModule("module"); mEngine->GarbageCollect(); }
Within the garbage collection call it crashes with the following error:
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
Here:
void CScriptArray::Release(){ // Now do the actual releasing (clearing the flag set by GC) gcFlag = false; if( --refCount == 0 ) { delete this; // everything wents well until this line }}
The strange things are:
1. The this pointer at this point seems to be correct.
2. The previous calls to release (refCount was up to 3) were all fine until he tries to delete the object.
3. For testing I removed the "virtual" keyword of the destructor and went into a completely different error within the script engine before he reaches the method above (!).
Especially the last thing sounds as if there is something realy mixed up. Any ideas where to look for this problem? I can probably simplify my environment more and provide if necessary...
Here is the stacktrace for the error mentioned above:
> Interpreter.exe!CScriptArray::Release() Line 499 + 0x29 bytes C++ Interpreter.exe!asCScriptEngine::CallObjectMethod(void * obj=0x01d9f378, asSSystemFunctionInterface * i=0x01d989f8, asCScriptFunction * s=0x01d98a70) Line 2879 + 0x8 bytes C++ Interpreter.exe!asCScriptEngine::CallObjectMethod(void * obj=0x01d9f378, int func=110) Line 2833 C++ Interpreter.exe!asCGarbageCollector::DestroyGarbage() Line 226 C++ Interpreter.exe!asCGarbageCollector::GarbageCollect(unsigned long flags=1) Line 94 + 0x8 bytes C++ Interpreter.exe!asCScriptEngine::GarbageCollect(unsigned long flags=1) Line 3212 C++ Interpreter.exe!AngelScriptInterpreter::reset() Line 117 + 0x1a bytes C++ Interpreter.exe!main(int argc=2, char * * argv=0x00377718) Line 62 C++ Interpreter.exe!__tmainCRTStartup() Line 597 + 0x19 bytes C Interpreter.exe!mainCRTStartup() Line 414 C kernel32.dll!7c817077() [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
I use the latest stable version of Angelscript. WinXP 32bit.
Thank you!
xad