🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Assert failure in asCExprValue::GetConstantDW

Started by
4 comments, last by WitchLord 6 years, 8 months ago

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!

Advertisement

I've fixed this in revision 2416.

Thanks,
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

That was quick, thanks :)

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.

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

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