Advertisement

TestExceptionMemory fails on Linux

Started by May 02, 2015 12:15 AM
13 comments, last by dkrusu 9 years, 4 months ago

The TestExceptionMemory fails on Linux at least with 64-Bit GCC v4.8.2. It never catches the std::exception that is thrown like I guess it's supposed to??


std::string ReturnStringButException()
{
	if( !strstr(asGetLibraryOptions(), "AS_NO_EXCEPTIONS") )
		throw std::exception(); // random exception. AngelScript will catch all the same way
	else
	{
		asIScriptContext *ctx = asGetActiveContext();
		if( ctx ) ctx->SetException("Caught an exception from the application");
	}

	return ""; // This is never returned so AngelScript has to properly handle the situation
}

The test produces the following


-- TestImport passed
-- TestAssign passed
-- TestSwitch passed
terminate called after throwing an instance of 'std::exception'
  what():  std::exception

GDB Backtrace:


rogram received signal SIGABRT, Aborted.
0x00007ffff700dcc9 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff700dcc9 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff70110d8 in __GI_abort () at abort.c:89
#2  0x00007ffff79186b5 in __gnu_cxx::__verbose_terminate_handler() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff7916836 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff7916863 in std::terminate() ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff7916aa2 in __cxa_throw ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x000000000045d574 in TestExceptionMemory::ReturnStringButException ()
    at ../../source/test_exceptionmemory.cpp:210
#7  0x00000000005cac0a in endstack ()
#8  0x0000000000404c70 in std::ios_base::Init::~Init()@plt ()
#9  0x00007fffffffe0b0 in ?? ()
#10 0x0000000000000000 in ?? ()

Looks like the stack unwinding failed. It is probably a problem in the assembler code.

I'll look into it.

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

Advertisement

I did a little more testing and it works on 32-Bit with GCC 4.7 thru 4.9.2. It fails on x64 with GCC 4.7 thru 4.9.2

thanks,

dkrusu

The 64bit Linux environment I have access to is still using GCC 4.4. The problem doesn't happen on that version.

Looks like there might be a minor change in GCC on how exception handling is implemented from 4.7 and onwards.

I'll have to investigate this further once I manage to get access to a more up-to-date Linux environment.

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

I've now managed to get access to a 64bit Linux env with GCC 4.8.3.

I'm not able to reproduce this problem with the latest WIP from the SVN.

What compiler options are you using?

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.3/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)

$ testgnuc
AngelScript version: 2.30.1 WIP
AngelScript options:  AS_64BIT_PTR AS_LINUX AS_X64_GCC
-- Test_Addon_ScriptFile passed
-- Test_Addon_ContextMgr passed
-- Test_Addon_ScriptGrid passed
-- Test_Addon_WeakRef passed
-- Test_Addon_Debugger passed
-- Test_Addon_ScriptBuilder passed
-- Test_Addon_ScriptMath passed
-- Test_Addon_Serializer passed
-- Test_Addon_ScriptHandle passed
-- Test_Addon_ScriptArray passed
-- Test_Addon_Dictionary passed
-- TestPropIntegerDivision passed
-- TestThisCallMethod_ConfigErrors passed
-- TestAuto passed
-- TestPow passed
-- TestMixin passed
-- TestNamespace passed
-- TestShared passed
-- TestDefaultArg passed
-- TestNamedArgs passed
-- TestScriptRetRef passed
-- TestGarbageCollect passed
-- TestFunctionPtr passed
-- TestModule passed
-- TestGetSet passed
-- TestOperator passed
-- TestTemplate passed
-- TestDump passed
-- TestInheritance passed
-- TestScriptClassMethod passed
-- TestScriptString passed
-- TestSaveLoad passed
-- TestInterface passed
-- TestCastOp passed
-- Test2Modules passed
-- TestArrayObject passed
-- TestCompiler passed
-- TestOptimize passed
-- TestConversion passed
-- TestRegisterType passed
-- TestRefArgument passed
-- TestStream passed
-- TestEnum passed
-- TestDynamicConfig passed
-- TestObjHandle passed
-- TestGlobalVar passed
-- TestScriptStruct passed
-- TestRZ passed
-- TestArray passed
-- TestAny passed
-- TestObjHandle2 passed
-- TestVector3 passed
-- TestConstObject passed
-- TestImplicitCast passed
-- TestImplicitHandle passed
-- TestFor passed
-- TestRefCast passed
TestStdWString is skipped because wstring is platform dependent and this test only works on Windows
-- TestStdString passed
-- TestStack2 passed
-- TestStdVector passed
-- TestArrayHandle passed
-- TestDict passed
-- TestMultiAssign passed
-- TestException passed
-- TestInt8 passed
-- TestGeneric passed
-- TestBStr passed
-- TestTypedef passed
-- TestImport passed
-- TestAssign passed
-- TestSwitch passed
-- TestExceptionMemory passed
-- TestObject passed
-- TestFactory passed
-- TestFuncOverload passed
-- TestObjZeroSize passed
-- TestSingleton passed
-- TestCondition passed
-- TestObject2 passed
-- TestShark passed
-- TestBool passed
-- TestBits passed
-- TestDestructor passed
-- TestConstructor2 passed
-- TestUnsafeRef passed
-- TestVarType passed
-- TestScriptMath passed
-- TestDebug passed
-- TestGetArgPtr passed
-- TestAutoHandle passed
-- TestObject3 passed
-- TestArrayIntf passed
-- TestConstProperty passed
-- TestSuspend passed
-- TestVector3_2 passed
-- TestNested passed
-- TestConstructor passed
-- TestExecuteScript passed
-- TestCustomMem passed
-- TestPostProcess passed
-- TestArgRef passed
-- TestNotInitialized passed
-- TestConfig passed
-- TestInt64 passed
-- TestImport2 passed
-- TestEnumGlobVar passed
-- TestConfigAccess passed
-- TestDiscard passed
-- TestParser passed
-- TestFloat passed
-- TestTempVar passed
-- TestModuleRef passed
-- TestExecuteString passed
-- TestStack passed
-- TestCreateEngine passed
-- TestLongToken passed
-- TestOutput passed
-- Test2Func passed
-- TestCircularImport passed
-- TestNeverVisited passed
-- TestReturnString passed
-- TestNegateOperator passed
-- TestExecute passed
-- TestCDeclReturn passed
-- TestExecute1Arg passed
-- TestExecute2Args passed
-- TestExecute4Args passed
-- TestExecute4Argsf passed
-- TestExecuteMixedArgs passed
-- TestExecute32Args passed
-- TestExecute32MixedArgs passed
-- TestCDecl_Class passed
-- TestCDecl_ClassA passed
-- TestCDecl_ClassC passed
-- TestCDecl_ClassD passed
-- TestCDecl_ClassK passed
-- TestCDeclObjLast passed
-- TestReturnWithCDeclObjFirst passed
-- TestExecuteThis32MixedArgs passed
-- TestThiscallClass passed
-- TestNotComplexThisCall passed
-- TestVirtualMethod passed
-- TestMultipleInheritance passed
TestVirtualInheritance: GNUC: AngelScript cannot detect virtual inheritance thus this test doesn't apply
-- TestVirtualInheritance passed
-- TestThiscallAsGlobal passed
-- TestThisCallMethod passed
-- TestStdcall4Args passed
-- TestNotComplexStdcall passed
---------
MEMORY STATISTICS
number of allocations                 : 747938
max allocated memory at any one time  : 4335767
max number of simultaneous allocations: 57228
total amount of allocated memory      : 98782959
medium size of allocations            : 132
--------------------------------------------
All of the tests passed with success.
 

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

I'm using the default makefiles, no changes the flags. Checked with GCC 4.9, 4.8, and 4.7 all fails the same way.

For some resaon the formatting wont work for me so here is a list of the versions and flags http://pastebin.com/96pspBzS

So maybe the issue has something to do with some of the flags Ubuntu uses to compile GCC? I'm downloading GCC 4.6, but I am on horribly slow wifi at the moment, i'll update when I get a chance.

Thanks

Advertisement

It also fails with GCC 4.6 and 4.4 which you said was workingm so obviously it has to be something Ubuntu either does, or a flag they enable that Redhat isn't.

Yes, it definitely appears to be a difference in how gnuc works on Ubuntu compared to RedHat.

Unfortunately I don't have access to Ubuntu (yet) so it will be difficult for me to discover and fix the problem :(

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

I get cable installed on Tuesday, when I do I'll give you access to a Ubuntu shell with GCC 4.4-4.9 64-Bit

That would be great. If I can just reproduce and debug the problem I'm sure it won't be difficult to fix.

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