Jump to content
  • Advertisement
Sign in to follow this  
mind in a box

Two NULL-Pointer exceptions in as_context.cpp

This topic is 2591 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


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

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!
return asINVALID_ARG;

Here is the code which called the function:
/** Sets the content mark we are linked to */
void EngineContentMarkScriptObject::SetContentMark(WContentMark* CM)

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

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

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?

Share this post

Link to post
Share on other sites
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.

Share this post

Link to post
Share on other sites
I scrapped the last 4-5 postings I wanted to write, so sorry for not responding yesterday.

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. :)

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!