# stackSize assertion

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

## Recommended Posts

Hey again, I'm triggering an assertion when compiling one of the scripts and I don't find what's wrong with it. The assertion is :
void asCByteCode::AddPath(asCArray<cByteInstruction *> &paths, cByteInstruction *instr, int stackSize)
{
if( instr->marked )
{
// Verify the size of the stack
asASSERT(instr->stackSize == stackSize);

And it happens at "engine->Build( module );". I only happens at one of the scripts, and the script doesn't seem to act any wrong in release. I wonder if you could help me with some guess about it.

##### Share on other sites
Any assert failures that happens inside the library are because of bugs in the library. I need to investigate this.

Can you give me the script code that you're compiling when the assert failure occurs. I also need to know what you're registering the engine, i.e. the types and functions.

Try to eliminate as much as possible from the engine configuration and script, while still reproduzing the assert failure. That way it will be easier for me to find the bug, and also less code for you to send.

Which version of AngelScript are you using, and on what platform?

Regards,
Andreas

##### Share on other sites
I'm using revision 274 of angelscript, which is, iirc, 2.13.1 + a bugfix revision. The assertion happens at both win32 and linux32 (not tested at any 64bits machine, so I don't know about those).

My code (both the script and the registration) is quite huge. I'll try to reduce it as much as I can.

##### Share on other sites
Good news. I've isolated the part of the script that produces the assertion. This function does trigger it:

cFlagBase @CTF_getBaseForOwner( cEntity @ent ){    for ( cFlagBase @flagBase = @fbHead; flagBase != null; @flagBase = @flagBase.next )    {        if ( @flagBase.owner == @ent )            return flagBase;    }    return null;}

While this different version of it doesn't trigger it

cFlagBase @CTF_getBaseForOwner( cEntity @ent ){    cFlagBase @ptr = @fbHead;    while ( ptr != null )    {        if ( @ptr.owner == @ent )            break;        @ptr = @ptr.next;    }    return ptr;}

In the full script the for loop style is used at many different places. All of them trigger the assertion.
I don't think you really need this, but this is a stripped down version of the class in question:

cFlagBase @fbHead = null;class cFlagBase{    cEntity @owner;    cEntity @carrier;    cFlagBase @next;    void Initialize( cEntity @owner )    {        @this.next = @fbHead;        @fbHead = @this;        @this.owner = @owner;        @this.carrier = @owner;    }    cFlagBase()    {        Initialize( null );    }    cFlagBase( cEntity @owner )    {        Initialize( owner );    }    ~cFlagBase()    {    }}

And the full script in case of any remaining doubt:

http://pastebin.com/f5daacf8a

EDIT: I'm gonna try removing the "compare pointers" global behavior I added to cEntity objects.

EDIT2: The compare behavior isn't it. The for loop still triggers the assert with the behavior removed and proper @ = @ comparisons. I modified the function examples reflecting it.

[Edited by - jal_ on September 17, 2008 4:59:56 AM]

##### Share on other sites
Thanks for the info. I've reproduced the problem with no engine configuration and this script:

class cFlagBase {}void CTF_getBaseForOwner( ){  for ( cFlagBase @flagBase; ; @flagBase = null )  {  }}

The problem seems to be with the last assignment in the loop, because if I remove that part the assert failure goes away.

I'll be back with a bug fix as soon as possible.

Regards,
Andreas

##### Share on other sites
The bug fix is now available in the SVN (revision 297)

Thanks a lot for the bug report.

1. 1
2. 2
frob
20
3. 3
Rutin
17
4. 4
5. 5

• 13
• 10
• 9
• 18
• 9
• ### Forum Statistics

• Total Topics
632555
• Total Posts
3007035

×