Are you calling AddRef on the asIScriptObject that you create? If you don't the object will be destroyed before it is time, and this can very well crash the GC.
Yes I am.
void Object::doCreate()
{
int id = scrType->GetFactoryIdByDecl( "ObjectController @ObjectController( Object @object)");
assert( id >= 0);
asIScriptContext *context = scriptEngine->GetContext();
if (context != NULL)
{
context->Prepare( id);
*((Object**)context->GetAddressOfArg(0)) = this;
AddRef();
int r = context->Execute();
if (r != asEXECUTION_FINISHED)
{
if (r == asEXECUTION_EXCEPTION)
{
const char *exception = context->GetExceptionString();
printf( "An Exception 's%' Occured In The Create Event.\n", exception);
return;
}
if (r == asERROR)
{
printf( "An Unexpected Error Occured In The Create Event.\n");
return;
}
}
else
{
scrObj = *(asIScriptObject**) context->GetAddressOfReturnValue();
scrObj->AddRef();
createCalled = true;
}
}
}