What do I need to change to reproduce the crash?
my engine can use multiply tabs, and any tab use asIScritpEngine. If exemple i open 5 tabs in debug mode, script compilation time ~2300 msec ( 5 tabs is over 10 second ), I all time use save and load byte code
Problem show after save and load byte code, use can use this exemple:
class CBytecodeStream : public asIBinaryStream
{
public:
CBytecodeStream() {wpointer = 0;rpointer = 0;}
void Write(const void *ptr, asUINT size)
{
if( size == 0 )
return;
buffer.resize(buffer.size() + size);
memcpy(&buffer[wpointer], ptr, size);
wpointer += size;
}
void Read(void *ptr, asUINT size)
{
memcpy(ptr, &buffer[rpointer], size);
rpointer += size;
}
int rpointer;
int wpointer;
std::vector<asBYTE> buffer;
} script_stream;
class TestLN
{
public:
void *TestLineNumber()
{
asIScriptContext *ctx = asGetActiveContext();
const char *script_section;
int line = ctx->GetLineNumber(0, 0, &script_section);
return 0;
}
};
void Reg( asIScriptEngine *engine ){
engine->RegisterInterface("foo");
engine->RegisterObjectType("Test", 0, asOBJ_REF | asOBJ_NOCOUNT);
engine->RegisterObjectMethod("Test", "foo @TestLineNumber()", asMETHOD(TestLN, TestLineNumber), asCALL_THISCALL);
TestLN t;
engine->RegisterGlobalProperty("Test test", &t);
}
bool Test()
{
bool fail = false;
// Test crash in GetLineNumber
// http://www.gamedev.net/topic/638656-crash-in-ctx-getlinenumber/
{
asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION);
Reg( engine );
asIScriptModule *mod = engine->GetModule("test", asGM_ALWAYS_CREATE);
mod->AddScriptSection("b"," // nothing to compile");
mod->AddScriptSection("a","foo @f = test.TestLineNumber();");
int r = mod->Build();
script_stream.wpointer = 0;
mod->SaveByteCode( &script_stream );
asIScriptEngine *engine2 = asCreateScriptEngine(ANGELSCRIPT_VERSION);
asIScriptModule *mod2 = engine2->GetModule(0, asGM_ALWAYS_CREATE );
Reg( engine2 );
script_stream.rpointer = 0;
mod2->LoadByteCode( &script_stream );
assert( r >= 0 );
engine->Release();
}
return fail;
}
I'm wondering about that as well You catch around two bugs every week
the Russian saying - not I such, life such