for( asUINT m = n+1; m < classDeclarations.GetLength(); m++ )
{
sClassDeclaration *declBase = classDeclarations[m]; // m not n!
....
Compiler crash with AngelScript 2.15.2
I hope this little bug doesn't turn you away from AngelScript. ;)
As AngelScript is still under heavy development it is likely to have a higher number of bugs than other mature scripting libraries. I am however usually quite quick with the bug fixes. I also do my best to avoid introducing new bugs in old code by having an extensive regression test suite that I run before every check-in.
Regards,
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
Quote: Original post by WitchLord
I hope this little bug doesn't turn you away from AngelScript. ;)
Nah still playing with it ;)
I found another compiler crash though. I'll try to describe the situation, it's a little complicated. Maybe I'm doing something wrong.
In the host application I created the Engine and registered a simple interface within a named configuration group.
Engine->BeginConfigGroup("MyGroup");Engine->RegisterInterface("MyHostDefinedInterface");Engine->RegisterInterfaceMethod("MyHostDefinedInterface", "void doSomething()");Engine->EndConfigGroup();
Everything is fine. Now I create a Module, load and Build() the following AngelScript:
class MyScriptedClass : MyHostDefinedInterface{ void doSomething() { /* nothing */ }};
The Build() is ok and I can use MyScriptedClass without problems.
Now (don't ask why :) I want to clean up and unload everything.
So I first Discard() the module and then I remove the configuration group "MyGroup". I guess the Engine is back to its initial state now (or very close to it).
Finally I'd like to load a different script containing another class that implements MyHostDefinedInterface. For the sake of simplicity I just reloaded the same script.
So I re-register my config group with the "MyHostDefinedInterface", create a new Module with the script and then Build().
The build now crashes with an out-of-bounds access to the array "scriptedFunctions" in the engine. I have no clue about what has gone wrong.
Sorry for the long description, if you can't reproduce the crash I'll send you an example.
Thank you.
I'll have to do some investigation, but it is likely that the cleanup is missing some stuff. Though it might have been fixed in 2.16.0 already, as I've done some rearrangement.
[edit]I've reproduced the problem. I should have a solution for it soon.[/edit]
[Edited by - WitchLord on March 24, 2009 10:39:01 AM]
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Move the location of the line func->objectType->methods.PushLast((int)scriptFunctions.GetLength()); to after func->id = GetNextScriptFunctionId(); and change it to be func->objectType->methods.PushLast(func->id);.
int asCScriptEngine::RegisterInterfaceMethod(const char *intf, const char *declaration){ ... func->objectType->methods.PushLast((int)scriptFunctions.GetLength()); // <-- Remove this line ... func->id = GetNextScriptFunctionId(); ... func->objectType->methods.PushLast(func->id); // <-- Add this line ...}
I'll check-in the fix as soon as possible.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Quote: Original post by WitchLord
Are you deliberately trying to find bugs? ;)
Really no, but we got one more crash I'm afraid ;)
This time it happens in the VM while executing. Try this:
static const char *script ="class B : A {} \n""void Test() \n""{ \n"" B @b = B(); \n""} \n";bool Test(){ bool fail = false; int r; asIScriptEngine *engine = asCreateScriptEngine(ANGELSCRIPT_VERSION); // Do the test, cleanup and do it again for (int times = 0; times < 2; ++times) { // Setup r = engine->BeginConfigGroup("myGroup"); assert( r >= 0 ); r = engine->RegisterInterface("A"); assert( r >= 0 ); r = engine->EndConfigGroup(); assert( r >= 0 ); asIScriptModule *mod = engine->GetModule(0, asGM_ALWAYS_CREATE); mod->AddScriptSection("myTest", script, strlen(script), 0); COutStream out; engine->SetMessageCallback(asMETHOD(COutStream,Callback), &out, asCALL_THISCALL); // Build r = mod->Build(); if( r < 0 ) fail = true; // Run asIScriptContext *context = 0; r = engine->ExecuteString(0, "Test();", &context); assert (r >= 0); // <-- crash on the second run context->Release(); // Cleanup engine->DiscardModule(0); r = engine->RemoveConfigGroup("myGroup"); assert( r >= 0 ); } engine->Release(); return fail;}
Just tested it against the last SVN, and crashes on the second iteration while executing:
void asCScriptEngine::CallObjectMethod(void *obj, int func){ asCScriptFunction *s = scriptFunctions[func]; // s->sysFuncIntf is NULL and CallObjectMethod won't like that... CallObjectMethod(obj, s->sysFuncIntf, s);}
I guess the problem with the removal of dynamic config groups and the improper cleanup of the engine is not completely solved.
In order to catch earlier these bugs, maybe you could improve your (already impressive) test suite by iterating some tests while keeping the same Engine instance like in my example.
Thank you, as always.
as_configgroup.cpp, line 138:
void asCConfigGroup::RemoveConfiguration(asCScriptEngine *engine){ ... // Remove behaviours and members of object types for( n = 0; n < objTypes.GetLength(); n++ ) { asCObjectType *obj = objTypes[n];// Add this --> // Only remove the members for interface types if( obj->flags & asOBJ_SCRIPT_OBJECT ) { for( m = 0; m < obj->methods.GetLength(); m++ ) { engine->DeleteScriptFunction(obj->methods[m]); } continue; }// <-- Add this ... } ...}
It's always difficult to foresee the tests that needs to be performed for a system as complex as a scripting library. I have quite a few tests that are very close to the situations you found bugs for, but none of them had exactly the same combination of conditions to trigger the bugs.
When I develop new features I always try to imagine all possible tests that needs to be done, but there will always be some things that are forgotten. Also, there comes a time when it becomes counter productive to try imagining more tests. Right now, any scenario that I can think of is almost certainly already covered by some test in the suite.
Unfortunately that is the sad reality of software development. You can never cover 100% of all possible scenarios, you can only come very close to it.
However, hopefully I have shown you that while you will inevitably come across more bugs in the library you can be sure that I will do my best to have them fixed right away. :)
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game