🎉 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!

Crash When Trying To Store Weakref In An Array

Started by
0 comments, last by WitchLord 7 years, 11 months ago

I seem to have some problems with weakref, first I couldn't even pass it to a function, now I tried storing it in an array and it just crashes. Maybe it wasn't designed to be stored like this (though it makes perfect sense to me), but I don't think it should crash so hard. The code to reproduce it looks like this:

class foo
{
}
int main()
{
array<weakref<foo>> arr;
foo f();
arr.push_back(weakref<foo>(f));
return 1;
}
It crashes on push_back, I tried first initializing weakref<foo>, then passing it both by value or reference, always crashed. Here is the callstack:
Program received signal SIGSEGV, Segmentation fault.
0x0000000000488799 in asCScriptEngine::CallGlobalFunctionRetPtr (this=0x7f5c20, i=0x0, s=0x82d710, param1=0x850380) at ../angelscript/angelscript/source/as_scriptengine.cpp:4363
4363 if( i->callConv == ICC_CDECL )
#0 0x0000000000488799 in asCScriptEngine::CallGlobalFunctionRetPtr (this=0x7f5c20, i=0x0, s=0x82d710, param1=0x850380) at ../angelscript/angelscript/source/as_scriptengine.cpp:4363
#1 0x0000000000488661 in asCScriptEngine::CallGlobalFunctionRetPtr (this=0x7f5c20, func=399, param1=0x850380) at ../angelscript/angelscript/source/as_scriptengine.cpp:4336
#2 0x000000000048a1ad in asCScriptEngine::CreateScriptObject (this=0x7f5c20, type=0x850380) at ../angelscript/angelscript/source/as_scriptengine.cpp:4935
#3 0x00000000004373b3 in CScriptArray::Construct (this=0x828fb0, buf=0x836300, start=0, end=1) at ../angelscript/add_on/scriptarray/scriptarray.cpp:951
#4 0x0000000000436f3b in CScriptArray::Resize (this=0x828fb0, delta=1, at=0) at ../angelscript/add_on/scriptarray/scriptarray.cpp:718
#5 0x0000000000437502 in CScriptArray::InsertAt (this=0x828fb0, index=0, value=0x855b98) at ../angelscript/add_on/scriptarray/scriptarray.cpp:793
#6 0x0000000000437829 in CScriptArray::InsertLast (this=0x828fb0, value=0x855b98) at ../angelscript/add_on/scriptarray/scriptarray.cpp:856
#7 0x00000000004cfdf8 in X64_CallFunction (args=0x7fffffffd8e0, cnt=0, func=0x437800 <CScriptArray::InsertLast(void*)>, retQW2=@0x7fffffffdb08: 0, returnFloat=false)
at ../angelscript/angelscript/source/as_callfunc_x64_gcc.cpp:162
#8 0x00000000004d09db in CallSystemFunctionNative (context=0x8281c0, descr=0x845500, obj=0x828fb0, args=0x855b8c, retPointer=0x0, retQW2=@0x7fffffffdb08: 0, secondObject=0x0)
at ../angelscript/angelscript/source/as_callfunc_x64_gcc.cpp:468
#9 0x00000000004cf759 in CallSystemFunction (id=425, context=0x8281c0) at ../angelscript/angelscript/source/as_callfunc.cpp:712
#10 0x0000000000460a79 in asCContext::ExecuteNext (this=0x8281c0) at ../angelscript/angelscript/source/as_context.cpp:2514
#11 0x000000000045db1f in asCContext::Execute (this=0x8281c0) at ../angelscript/angelscript/source/as_context.cpp:1296
#12 0x0000000000450cd6 in CContextMgr::ExecuteScripts (this=0x80e790) at ../angelscript/add_on/contextmgr/contextmgr.cpp:177
#13 0x0000000000407cce in ExecuteScript (engine=0x7f5c20, scriptFile=0x54740d "arr_weakref.as", debug=false) at ../game/main.cpp:522
#14 0x0000000000406d36 in main (argc=1, argv=0x7fffffffe5e8) at ../game/main.cpp:126

Unfortunately this goes beyond my ability to debug Angelscript so I just hope someone can see what goes wrong here. If needed I can supply more info - just tell me what.


Where are we and when are we and who are we?
How many people in how many places at how many times?
Advertisement

This was a bug in asIScriptEngine::CreateScriptObject when used to create an instance of a template value type (which is what the weakref type is).

I've fixed this in revision 2339.

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