Two NULL-Pointer exceptions in as_context.cpp

Started by
2 comments, last by WitchLord 12 years, 11 months ago
Hello,

It hasn't been much time since I started using AngelScript, so I that 'bug' was maybe my own vault. (If so I'd really appreciate to hear a solution for it)

Sometimes when I just compiled one of my tiny test-scripts I get an exception in as_context.cpp.

It is this code which makes trouble (Line: ~1027, Execute() )
if( status == asEXECUTION_FINISHED )
{
regs.objectType = initialFunction->returnType.GetObjectType(); // <-- initialFunction is NULL
return asEXECUTION_FINISHED;
}


After messing around with this for a while I noticed that this only happens when I use a different package than my EngineMedia package to load the script.
Some background information:
My Engine stores all data in some kind of package-file. Each file stored there has it's own File-Chunk which simply holds the Data and some other properties.
The EngineMedia-Package is the first loaded package of my engine.

When I link a script to a "ContentMark", which is an Object which links to some Content or Actor with some Components in one of the packages, the Package and the FileChunk will be grabbed from
the selection the user made in the Browser of the Editor.
Then that ContentMark gets those Pointers and then gets the Data out.
And then we simply have a char-array and every package related work is done.

The char-array will be given to the ScriptEngine, which compiles it just fine, and then, when I call my first function it crashes.

Because of that weird thing I have going on with the different packages I guess the problem was maybe caused by myself, but I thought you should know about another possible exception in your great library. ;)

---

Also got that error in line 751 of as_context.cpp ( SetArgAddress(...) ):
if( arg >= (unsigned)initialFunction->parameterTypes.GetLength() ) // <-- initialFunction NULL again!
{
status = asEXECUTION_ERROR;
return asINVALID_ARG;
}


Here is the code which called the function:
/** Sets the content mark we are linked to */
void EngineContentMarkScriptObject::SetContentMark(WContentMark* CM)
{
ContentMark=CM;
CMScriptObject=CM->GetInScriptObject();

int SetCMIdx = Module->GetFunctionIdByName("ENGINE_SetContentMark");

if(Context->Prepare(SetCMIdx) >= 0)
{
Context->SetArgAddress(0, (void *)CMScriptObject); // <-- That
Context->Execute();
}
CallOnLoad();
}


That works when compiling the code out of another package. Can't tell why.

(And also, sorry for the weird and confusing posting, I had new ideas to try out after writing every single line...)

Someone got an idea what is going on?
Advertisement
There is definitely something weird going on. In order to get to the code where you're getting the null-pointer access the context must have been successfully prepared, which means the initialFunction must have been properly initialized, thus you shouldn't be getting the null-pointer access. I believe you have found a bug in AngelScript, most likely due to some unusual way of doing things. However, I have no idea as to where the bug might be, and I'll need your help in finding a simple way of reproducing the problem so I can have it fixed.

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 scrapped the last 4-5 postings I wanted to write, so sorry for not responding yesterday.

But!
I found the solution, and it wasn't even a bug in AngelScript I think.
The main problem was that I was somehow calling script functions from different threads using the same context and I forgot to use a mutex with it.

Just wanted to let you know that it's all good. :)
Ah, yes that would definitely cause problems like this. Thanks for clarifying :)

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