Advertisement

Assert failure when evaluating const bool as false in if-statement

Started by September 29, 2016 10:08 PM
2 comments, last by WitchLord 8 years, 1 month ago

After upgrading to angelscript 2.31.1 from angelscript 2.30.0 the following block of code will cause a runtime assert failure when compiling


bool Init() {
    const bool show_invisible = false;
    if(show_invisible == false) {
        Print("Hello");
    }
}

Removing const from the bool makes the problem disappear. Evaluating if the bool is true does not cause a problem however. Following is a stack trace from the crash.


#3  0x00007ffff0a58312 in __GI___assert_fail (assertion=0x1500f38 "dataType.GetSizeInMemoryBytes() == 4", file=0x14fe4d8 "/mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp", line=14783, function=0x1504480 <asCExprValue::GetConstantDW()::__PRETTY_FUNCTION__> "asDWORD asCExprValue::GetConstantDW()") at assert.c:101
#4  0x000000000110ba14 in asCExprValue::GetConstantDW (this=0x262e7a8) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:14783
#5  0x000000000110792b in asCCompiler::CompileComparisonOperator (this=0x7ffffffeca50, node=0x27a60f0, lctx=0x262e740, rctx=0x262e850, ctx=0x262e960, op=ttEqual) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:13828
#6  0x0000000001101d89 in asCCompiler::CompileOperator (this=0x7ffffffeca50, node=0x27a60f0, lctx=0x262e740, rctx=0x262e850, ctx=0x262e960, op=ttEqual) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:12616
#7  0x00000000010ee9c1 in asCCompiler::CompilePostFixExpression (this=0x7ffffffeca50, postfix=0x7ffffffebb50, ctx=0x7ffffffec4c0) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:8398
#8  0x00000000010ee5a7 in asCCompiler::CompileExpression (this=0x7ffffffeca50, expr=0x2761f40, ctx=0x7ffffffec4c0) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:8328
#9  0x00000000010ee37e in asCCompiler::CompileCondition (this=0x7ffffffeca50, expr=0x2ca5bf0, ctx=0x7ffffffec4c0) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:8314
#10 0x00000000010ecc7d in asCCompiler::CompileAssignment (this=0x7ffffffeca50, expr=0x2c8aee0, ctx=0x7ffffffec4c0) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:7990
#11 0x00000000010dacaa in asCCompiler::CompileIfStatement (this=0x7ffffffeca50, inode=0x2ca5ba0, hasReturn=0x7ffffffec95f, bc=0x7ffffffec720) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:4119
#12 0x00000000010d9615 in asCCompiler::CompileStatement (this=0x7ffffffeca50, statement=0x2ca5ba0, hasReturn=0x7ffffffec95f, bc=0x7ffffffec720) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:3762
#13 0x00000000010ce0e1 in asCCompiler::CompileStatementBlock (this=0x7ffffffeca50, block=0x27f1060, ownVariableScope=false, hasReturn=0x7ffffffec95f, bc=0x7ffffffec880) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:1148
#14 0x00000000010cbcfc in asCCompiler::CompileFunction (this=0x7ffffffeca50, in_builder=0x262acb0, in_script=0x26288b0, in_parameterNames=..., in_func=0x26a1020, in_outFunc=0x262b140, in_classDecl=0x0) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_compiler.cpp:554
#15 0x00000000010a6e13 in asCBuilder::CompileFunctions (this=0x262acb0) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_builder.cpp:905
#16 0x00000000010a43b7 in asCBuilder::Build (this=0x262acb0) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_builder.cpp:306
#17 0x0000000001111850 in asCModule::Build (this=0x2c3e100) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_module.cpp:322
#18 0x0000000000d8bd75 in ASModule::CompileScript (this=0x2807540, path="Data/Scripts/level.as") at /mnt/FAST_DRIVE/MyGame/Source/Scripting/angelscript/asmodule.cpp:330
#19 0x0000000000d6aecb in ASContext::CompileScript (this=0x2807530, path="Data/Scripts/level.as") at /mnt/FAST_DRIVE/MyGame/Source/Scripting/angelscript/ascontext.cpp:35
#20 0x0000000000d6c424 in ASContext::LoadScript (this=0x2807530, path="Data/Scripts/level.as") at /mnt/FAST_DRIVE/MyGame/Source/Scripting/angelscript/ascontext.cpp:243
#21 0x0000000000a47dda in Level::Initialize (this=0x2819230, scenegraph=0x27c5010, gui=0x7fffe4b32028) at /mnt/FAST_DRIVE/MyGame/Source/Game/level.cpp:91
#22 0x0000000000c99bfe in Engine::LoadQueuedLevel (this=0x7fffe4b32010) at /mnt/FAST_DRIVE/MyGame/Source/Main/engine.cpp:3301
#23 0x0000000000c8c5f9 in Engine::Update (this=0x7fffe4b32010) at /mnt/FAST_DRIVE/MyGame/Source/Main/engine.cpp:1185
#24 0x0000000000c61c74 in GameMain (argc=1, argv=0x7fffffffe438) at /mnt/FAST_DRIVE/MyGame/Source/Main/main.cpp:112
#25 0x0000000000e4c19c in RunWithCrashReport (argc=1, argv=0x7fffffffe438, func=0xc619ab <GameMain(int, char**)>) at /mnt/FAST_DRIVE/MyGame/Source/Internal/crashreport.cpp:439
#26 0x0000000000c636fa in main (argc=1, argv=0x7fffffffe438) at /mnt/FAST_DRIVE/MyGame/Source/Main/main.cpp:283


This happens on an amd64 linux platform. Example is from placing the block of code in an otherwise empty script file

Thanks. This looks to be similar to the problem fixed in revision 2349, but at a different location in the code.

I'll have it fixed too.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement

Cool, glad i could be of service.

I've now fixed this problem in revision 2354.

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