Jump to content
  • Advertisement
Asu

Assert failure in asCExprValue::GetConstantDW

Recommended Posts

Hello, I am upgrading AngelScript on a game engine. I get an assertion failure strinkingly similar to this one.
I have AS_DEPRECATED set but I do not think it matters here.

Edit: Forgot to specify: amd64 linux with revision 2414 from SVN.

An assertion failure occurs in GetConstantDW.

../../source/as_compiler.cpp:15091: asDWORD asCExprValue::GetConstantDW(): Assertion `dataType.GetSizeInMemoryBytes() == 4' failed.

The backtrace is as it follows:

#6  0xf6bd685d in asCCompiler::CompileComparisonOperator(asCScriptNode*, asCExprContext*, asCExprContext*, asCExprContext*, eTokenType) ()
#7  0xf6bbeb5c in asCCompiler::CompileOperator(asCScriptNode*, asCExprContext*, asCExprContext*, asCExprContext*, eTokenType, bool) ()
#8  0xf6bb10c7 in asCCompiler::CompilePostFixExpression(asCArray<asCScriptNode*>*, asCExprContext*) ()
#9  0xf6bb1991 in asCCompiler::CompileExpression(asCScriptNode*, asCExprContext*) ()
#10 0xf6bb2ada in asCCompiler::CompileCondition(asCScriptNode*, asCExprContext*) ()
#11 0xf6bb3560 in asCCompiler::CompileAssignment(asCScriptNode*, asCExprContext*) ()
#12 0xf6be3172 in asCCompiler::CompileIfStatement(asCScriptNode*, bool*, asCByteCode*) ()
#13 0xf6be08d0 in asCCompiler::CompileStatementBlock(asCScriptNode*, bool, bool*, asCByteCode*) ()
#14 0xf6be0f48 in asCCompiler::CompileFunction(asCBuilder*, asCScriptCode*, asCArray<asCString>&, asCScriptNode*, asCScriptFunction*, sClassDeclaration*) ()
#15 0xf6b74520 in asCBuilder::CompileFunctions() ()

The script that triggers this is a comparison against a constant unsigned int:

const uint16 FREQUENCY = 2000;

/* ommitting some code */

void onTick(CBlob@ blob)
{
  if (blob.getTickSinceCreated() < FREQUENCY) return;
  /* ... */
}

blob.getTickSinceCreate() is returning an int. Removing the if condition makes the assertion failure go away.

I get the same failure with another script:

const u8 COIN_COST = 60;

void blah()
{
    if(/* ... */ && player.getCoins() < COIN_COST) { /* ... */ }
}

I'd love to have this fixed. Thanks!

Edited by Asu

Share this post


Link to post
Share on other sites
Advertisement

New crash case:

const uint8 constant = 5;

void foo()
{
	-constant;
}

Backtrace:

#6  0xf6b7ad6b in asCCompiler::CompileExpressionPreOp(asCScriptNode*, asCExprContext*) ()
#7  0xf6b5ba55 in asCCompiler::CompileExpressionTerm(asCScriptNode*, asCExprContext*) ()
#8  0xf6b5c3b0 in asCCompiler::CompilePostFixExpression(asCArray<asCScriptNode*>*, asCExprContext*) ()
#9  0xf6b5c9b1 in asCCompiler::CompileExpression(asCScriptNode*, asCExprContext*) ()
#10 0xf6b5daea in asCCompiler::CompileCondition(asCScriptNode*, asCExprContext*) ()
#11 0xf6b5e570 in asCCompiler::CompileAssignment(asCScriptNode*, asCExprContext*) ()
#12 0xf6b8292c in asCCompiler::CompileExpressionStatement(asCScriptNode*, asCByteCode*) ()
#13 0xf6b8bb90 in asCCompiler::CompileStatementBlock(asCScriptNode*, bool, bool*, asCByteCode*) ()
#14 0xf6b8c208 in asCCompiler::CompileFunction(asCBuilder*, asCScriptCode*, asCArray<asCString>&, asCScriptNode*, asCScriptFunction*, sClassDeclaration*) ()

Hopefully it's the last one.

Share this post


Link to post
Share on other sites

Thanks for providing the snippets for reproducing the problems. It makes it so much easier to identify and fix the bugs.

I've fixed this latest one in revision 2418.

Regards,
Andreas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!