Hi!
I'm using the latest version of angelscript 2.31.1, same issue appeared on 2.30.0
I have a problem when storing bytecode after some new objects and values where registered into our angelscript environment.
When trying to store successfully compile angelscript code there's a failing assert in as_restore.cpp:4541 where offset == currOffset is mismatching.
According to my debugger offset is 3 while currOffset is 4. Running the application in release mode will make the bytecode output fail and reload crash instead.
Following is a more or less complete stack trace.
#4 0x0000000001136181 in asCWriter::AdjustGetOffset (this=0x7ffffffeed20, offset=3, func=0x276c5d0, programPos=27) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_restore.cpp:4541
#5 0x000000000113691c in asCWriter::WriteByteCode (this=0x7ffffffeed20, func=0x276c5d0) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_restore.cpp:4708
#6 0x00000000011338c3 in asCWriter::WriteFunction (this=0x7ffffffeed20, func=0x276c5d0) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_restore.cpp:3834
#7 0x0000000001134e24 in asCWriter::WriteGlobalProperty (this=0x7ffffffeed20, prop=0x276c780) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_restore.cpp:4169
#8 0x0000000001132e5c in asCWriter::Write (this=0x7ffffffeed20) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_restore.cpp:3596
#9 0x00000000011133ba in asCModule::SaveByteCode (this=0x25c9360, out=0x7ffffffef3b0, stripDebugInfo=false) at /mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_1_sdk/angelscript/source/as_module.cpp:1603
#10 0x0000000000d8a705 in ASModule::CompileScript (this=0x250cb60, path="Data/Scripts/mainmenu.as") at /mnt/FAST_DRIVE/MyGame/Source/Scripting/angelscript/asmodule.cpp:374
#11 0x0000000000d6965d in ASContext::CompileScript (this=0x250cb50, path="Data/Scripts/mainmenu.as") at /mnt/FAST_DRIVE/MyGame/Source/Scripting/angelscript/ascontext.cpp:35
#12 0x0000000000d6ab9d in ASContext::LoadScript (this=0x250cb50, path="Data/Scripts/mainmenu.as") at /mnt/FAST_DRIVE/MyGame/Source/Scripting/angelscript/ascontext.cpp:243
#13 0x0000000000c56dc0 in ScriptableUI::Initialize (this=0x250ce20, script_path="Data/Scripts/mainmenu.as", as_data=...) at /mnt/FAST_DRIVE/MyGame/Source/GUI/scriptable_ui.cpp:62
#14 0x0000000000c8ac12 in Engine::Update (this=0x7fffe4b32010) at /mnt/FAST_DRIVE/MyGame/Source/Main/engine.cpp:1163
#15 0x0000000000c60406 in GameMain (argc=1, argv=0x7fffffffe448) at /mnt/FAST_DRIVE/MyGame/Source/Main/main.cpp:112
#16 0x0000000000e4982e in RunWithCrashReport (argc=1, argv=0x7fffffffe448, func=0xc6013d <GameMain(int, char**)>) at /mnt/FAST_DRIVE/MyGame/Source/Internal/crashreport.cpp:439
#17 0x0000000000c61e8c in main (argc=1, argv=0x7fffffffe448) at /mnt/FAST_DRIVE/MyGame/Source/Main/main.cpp:283
Following the stack up i can deduce that the data which is being stored belongs to a global value which is an instance of the following object registration.
ctx->RegisterGlobalFunction("vec4 HexColor(const string &in hex)", asFUNCTION(HexColor), asCALL_CDECL);
ctx->RegisterObjectType("FontSetup", sizeof(FontSetup), asOBJ_VALUE | asOBJ_APP_CLASS_CDAK );
ctx->RegisterObjectBehaviour("FontSetup", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(FontSetup_ASconstructor_default), asCALL_CDECL_OBJFIRST );
ctx->RegisterObjectBehaviour("FontSetup", asBEHAVE_CONSTRUCT, "void f( const string &in _name, int32 _size, vec4 _color, bool _shadowed = false )", asFUNCTION(FontSetup_ASconstructor_params), asCALL_CDECL_OBJFIRST );
ctx->RegisterObjectBehaviour("FontSetup", asBEHAVE_CONSTRUCT, "void f( const FontSetup &in other )", asFUNCTION(FontSetup_AScopy), asCALL_CDECL_OBJFIRST );
ctx->RegisterObjectMethod("FontSetup", "FontSetup& opAssign(const FontSetup &in other)", asFUNCTION(FontSetup_ASassign), asCALL_CDECL_OBJFIRST);
ctx->RegisterObjectBehaviour("FontSetup", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(FontSetup_ASdestructor), asCALL_CDECL_OBJFIRST );
ctx->RegisterObjectProperty("FontSetup",
"string fontName",
asOFFSET(FontSetup, fontName));
ctx->RegisterObjectProperty("FontSetup",
"int size",
asOFFSET(FontSetup, size));
ctx->RegisterObjectProperty("FontSetup",
"vec4 color",
asOFFSET(FontSetup, color));
ctx->RegisterObjectProperty("FontSetup",
"float rotation",
asOFFSET(FontSetup, rotation));
ctx->RegisterObjectProperty("FontSetup",
"bool shadowed",
asOFFSET(FontSetup, shadowed));
Does anyone have experience with this particular issue and can give me some error searching hints?