Advertisement

[2.15.2] Crash in Build() when using undefined variable

Started by March 26, 2009 06:47 PM
0 comments, last by WitchLord 15 years, 8 months ago
Hi! I recently made some changes to a script and caused a crash in the Build() function. I made a very small test script to test it and sure enough I can reproduce it every time. The only requirements are that you've registered a function using RegisterGlobalFunction. Just register a return type of bool and a single param, doesn't matter what type the param is. For example: bool MyCFunction(int aValue); // <- My function engine->RegisterGlobalFunction("bool MyCFunction(int aValue)", asFUNCTION(MyCFunction), asCALL_CDECL); // The AS registration of the above function And now use the following AngelScript code:
void main()
{
	if (true and MyCFunction( SomethingUndefined ))
	{
	}
}
If you remove the "true and" from the front, it will work fine and generate an error without crashing. In my case it was actually another compare such as someVariable == 4, you just need a condition check before the call to the function. If you define SomethingUndefined then there is no longer a crash, if you don't, there's a crash. Callstack as follows (I trimmed the params so it fits in the post):
>	MyExe.exe!_wassert  Line 384	C
 	MyExe.exe!asCCompiler::ConvertToVariableNotIn  Line 7481 + 0x26 bytes	C++
 	MyExe.exe!asCCompiler::ConvertToVariable  Line 7433	C++
 	MyExe.exe!asCCompiler::CompileBooleanOperator  Line 8497	C++
 	MyExe.exe!asCCompiler::CompileOperator  Line 7315	C++
 	MyExe.exe!asCCompiler::CompilePostFixExpression  Line 5121 + 0x1e bytes	C++
 	MyExe.exe!asCCompiler::CompileExpression  Line 5080 + 0x10 bytes	C++
 	MyExe.exe!asCCompiler::CompileCondition  Line 5035 + 0x10 bytes	C++
 	MyExe.exe!asCCompiler::CompileAssignment  Line 4861	C++
 	MyExe.exe!asCCompiler::CompileIfStatement  Line 2185	C++
 	MyExe.exe!asCCompiler::CompileStatement  Line 1857 + 0x14 bytes	C++
 	MyExe.exe!asCCompiler::CompileStatementBlock  Line 607	C++
 	MyExe.exe!asCCompiler::CompileFunction  Line 370	C++
 	MyExe.exe!asCBuilder::CompileFunctions  Line 408	C++
 	MyExe.exe!asCBuilder::Build  Line 169	C++
Let me know if you need anymore information. Cliff :)

Founder, Programmer, Designer and Artist of Forgotten Artifacts, my ARPG Blockchain Video game!

Thanks Cliff,

this happened because the compiler tries to continue the compilation after the error with the undefined variable. It's only a problem in debug mode.

Anyway, I've checked in the fix in the SVN (rev 388). Check the change in as_compiler.cpp for the fix.

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