• Advertisement
Sign in to follow this  

assert failure when saving bytecode in AdjustGetOffset, linux amd64

This topic is 566 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement

Have you tried the latest 2.31.2 WIP version? I think this might be related to a bug that was fixed a few weeks back in revision 2345.

 

 

Otherwise, can you show me the source code for the script function that is being saved when that error occurs so I can try to reproduce the problem? 

Share this post


Link to post
Share on other sites

Thanks for being so incredibly involved in regards to these problems, it's amazing.

I'll try the WIP version first thing in the morning. (It's getting late in the Swedish timezone).

 

The script function being saved is to the best of my guesses the constructor of a registered Object from the C++ side. More specifically the saving routine is referencing a global value which has an explicit constructor declaration.

 

The value declaration in the script looks as following: 

FontSetup selectionListFont("OpenSans-Regular", 70, white, true);

The function which the value type constructor is registered to call looks as follows:

static void FontSetup_ASconstructor_params(FontSetup *self, std::string const& _name, int32_t _size, vec4 _color, bool _shadowed = false ) {
    new(self) FontSetup(  _name, _size, _color, _shadowed );
}

I know this isn't enough to go on for a reproduction, just wanted to give some additional insight. I'll get back with more information after trying the WIP version and we'll go on from there.

Share this post


Link to post
Share on other sites

When trying to compile current trunk i get the following compile error:

[ 35%] Building CXX object angelscript_2_31_2_r2352/CMakeFiles/angelscript.dir/__/__/source/as_string_util.cpp.o
/mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_2_r2352/angelscript/source/as_string_util.cpp: In function ‘asQWORD asStringScanUInt64(const char*, int, size_t*, bool*)’:
/mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_2_r2352/angelscript/source/as_string_util.cpp:188:28: error: ‘MAXUINT64’ was not declared in this scope
    if( overflow && ((res > MAXUINT64 / 10) || ((*end - '0') > (MAXUINT64 - (MAXUINT64 / 10) * 10)) && res == MAXUINT64 / 10) )
                            ^
/mnt/FAST_DRIVE/MyGame/Projects/angelscript_2_31_2_r2352/angelscript/source/as_string_util.cpp:215:29: error: ‘MAXUINT64’ was not declared in this scope
     if (overflow && ((res > MAXUINT64 / base) || (nbr > (MAXUINT64 - (MAXUINT64 / base) * base)) && res == MAXUINT64 / base) )

MAXUINT64 does not seem to be defined in the project and isn't mentioned in 2.31.1

I'm going to define the value to something sane and continue testing the WIP, but i felt it was worth mentioning, 

 

I believe in C99 UINT64_MAX is a standards defined value. http://en.cppreference.com/w/c/types/integer

 

The revision is  2352

Edited by Autious

Share this post


Link to post
Share on other sites

After fixing the compile issue the libs build without problems. 

 

The original error still remains however. 

 

Will try and nail down what conditions are triggering this error.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement