Jump to content
  • Advertisement

Boost113

Member
  • Content Count

    19
  • Joined

  • Last visited

Community Reputation

109 Neutral

About Boost113

  • Rank
    Member

Personal Information

Social

  • Github
    hhyyrylainen
  1. Boost113

    Error when assigning script object to dictionary

    I ran my full code again with valgrind (with the added "@") and I'm no longer getting any errors related to the scripts (just some other stuff like uninitialized values used deep in other libraries). So I think that also fixes my full code as I don't get any messages on shutdown and valgrind is quiet after I trigger that code. My full code is here if you want to have a look: https://github.com/Revolutionary-Games/Thrive/blob/fix_everything/scripts/microbe_stage/microbe_editor/microbe_editor.as#L296 You are correct that my example code can be fixed by adding a default constructor for PlacedOrganelle. I tried more accurately following what my actual code looks like like this: class Organelle{ Organelle(const string &in name, int cost) { this.cost = cost; this.name = name; } int cost; string name; } class PlacedOrganelle{ // Default constructor doesn't help // PlacedOrganelle(){} PlacedOrganelle(Organelle@ organelle, int q, int r, int rotation) { @this._organelle = organelle; this.q = q; this.r = r; this.rotation = rotation; } PlacedOrganelle(PlacedOrganelle@ typefromother, int q, int r, int rotation) { @this._organelle = typefromother._organelle; this.q = q; this.r = r; this.rotation = rotation; } PlacedOrganelle(PlacedOrganelle@ other) { @this._organelle = other._organelle; this.q = other.q; this.r = other.r; this.rotation = other.rotation; // _commonConstructor(); } ~PlacedOrganelle() { } int q; int r; int rotation; const Organelle@ organelle { get const{ return _organelle; } } private Organelle@ _organelle; } void RunTest() { PlacedOrganelle@ organelle = PlacedOrganelle(Organelle("cytoplasm", 10), 1, 1, 0); dictionary data; data["organelle"] = organelle; PlacedOrganelle@ organelle2 = cast<PlacedOrganelle>(data["organelle"]); } And I now get (even when I add a default constructor for PlacedOrganelle) a segmentation fault: Program received signal SIGSEGV, Segmentation fault. 0x00000000008db160 in ?? () 0 in ?? 1 in asCScriptEngine::CallObjectMethod(void*, asSSystemFunctionInterface*, asCScriptFunction*) const of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_scriptengine.cpp:4024 2 in asCContext::ExecuteNext of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_context.cpp:2813 3 in asCContext::Execute() of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_context.cpp:1324 4 in Leviathan::ScriptExecutor::RunScript<void> of /home/hhyyrylainen/Projects/Leviathan/Engine/Script/ScriptExecutor.h:802 5 in Leviathan::ScriptExecutor::RunScript<void> of /home/hhyyrylainen/Projects/Leviathan/Engine/Script/ScriptExecutor.h:86 6 in ____C_A_T_C_H____T_E_S_T____34 of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/TestFiles/Script.cpp:791 7 in Catch::TestCase::invoke of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/catch/catch.hpp:10910 8 in Catch::RunContext::invokeActiveTestCase() of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/catch/catch.hpp:9774 9 in Catch::RunContext::runCurrentTest(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/catch/catch.hpp:9748 10 in Catch::RunContext::runTest(Catch::TestCase const&) of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/catch/catch.hpp:9524 11 in Catch::(anonymous namespace)::runTests of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/catch/catch.hpp:10073 12 in Catch::Session::runInternal() of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/catch/catch.hpp:10266 13 in Catch::Session::run of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/catch/catch.hpp:10223 14 in Catch::Session::run<char> of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/catch/catch.hpp:13744 15 in main of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/catch/catch.hpp:13744 16 in __libc_start_main of /lib64/libc.so.6 17 in _start of /home/hhyyrylainen/Projects/Leviathan/LeviathanTest/catch/catch.hpp:14069 I was able to extract this callstack with gdb from the asContext: > /home/hhyyrylainen/Projects/Leviathan/build/bin/Data/Scripts/tests/AnonymousDelegateLeak.as:72 void RunTest() Line 72 is the last line of the file and the closing } for function RunTest so it crashes when exiting the function, I presume.
  2. Hi, I got these strange errors in my application: [SCRIPT] [ERROR] (0, 0) : Object {245683}. GC cannot destroy an object of type '�t|' as it doesn't know how many references to there are. [SCRIPT] [ERROR] (0, 0) : Object {245593}. GC cannot destroy an object of type '�t|' as it doesn't know how many references to there are. [SCRIPT] [ERROR] (0, 0) : Object {245677}. GC cannot destroy an object of type '�t|' as it doesn't know how many references to there are. The type string is always different. And Valgrind says this: ==29943== Invalid read of size 4 ==29943== at 0x5188E00: asCAtomic::get() const (as_atomic.cpp:52) ==29943== by 0x51A1761: asCScriptEngine::CallObjectMethodRetInt(void*, int) const (as_scriptengine.cpp:4203) ==29943== by 0x5192A71: asCGarbageCollector::DestroyOldGarbage() (as_gc.cpp:564) ==29943== by 0x519370D: asCGarbageCollector::GarbageCollect(unsigned int, unsigned int) (as_gc.cpp:238) ==29943== by 0x519DD03: asCScriptEngine::GarbageCollect(unsigned int, unsigned int) (as_scriptengine.cpp:4636) ==29943== by 0x5190261: asCContext::Execute() (as_context.cpp:1356) ==29943== by 0x4FDF9A4: RunScriptMethod<void> (ScriptExecutor.h:196) ==29943== by 0x4FDF9A4: Leviathan::ScriptSystemWrapper::CreateAndDestroyNodes() (ScriptSystemWrapper.cpp:134) ==29943== by 0x4FD2D28: Leviathan::GameWorld::HandleAddedAndDeleted() (GameWorld.cpp:593) ==29943== by 0x4FF09A5: Leviathan::StandardWorld::HandleAddedAndDeleted() (StandardWorld.cpp:690) ==29943== by 0x4FD87F3: Leviathan::GameWorld::Tick(int) (GameWorld.cpp:528) ==29943== by 0x4FA1F1E: Leviathan::Engine::Tick() (Engine.cpp:895) ==29943== by 0x507FB0F: Leviathan::LeviathanApplication::RunMessageLoop() (Application.cpp:137) ==29943== Address 0x9e2a2c40 is 16 bytes inside a block of size 148 free'd ==29943== at 0x4C2FDAC: free (vg_replace_malloc.c:530) ==29943== by 0x51AE63A: asCScriptObject::Release() const (as_scriptobject.cpp:647) ==29943== by 0x51A1120: asCScriptEngine::CallObjectMethod(void*, asSSystemFunctionInterface*, asCScriptFunction*) const (as_scriptengine.cpp:4050) ==29943== by 0x518FE03: asCContext::ExecuteNext() (as_context.cpp:2813) ==29943== by 0x519011C: asCContext::Execute() (as_context.cpp:1324) ==29943== by 0x50296FC: Leviathan::ScriptRunResult<int> Leviathan::ScriptExecutor::RunScriptMethod<int, Leviathan::GenericEvent*&>(Leviathan::ScriptRunningSetup&, asIScriptFunction*, void*, Leviathan::GenericEvent*&) (ScriptExecutor.h:196) ==29943== by 0x502BF2A: non-virtual thunk to Leviathan::Script::EventListener::OnGenericEvent(Leviathan::GenericEvent*) (new_allocator.h:125) ==29943== by 0x50724CC: Leviathan::EventHandler::CallEvent(Leviathan::GenericEvent*) (EventHandler.cpp:65) ==29943== by 0x50608DA: CallEvent (EventHandler.h:38) ==29943== by 0x50608DA: Leviathan::GUI::View::OnProcessMessageReceived(scoped_refptr<CefBrowser>, cef_process_id_t, scoped_refptr<CefProcessMessage>) (GuiView.cpp:860) ==29943== by 0x51328D6: (anonymous namespace)::client_on_process_message_received(_cef_client_t*, _cef_browser_t*, cef_process_id_t, _cef_process_message_t*) (client_cpptoc.cc:264) ==29943== by 0x77EC397: ??? (in /home/hhyyrylainen/Projects/thrive/build/bin/lib/libcef.so) ==29943== by 0x93A7639: ??? (in /home/hhyyrylainen/Projects/thrive/build/bin/lib/libcef.so) ==29943== Block was alloc'd at ==29943== at 0x4C2EBAB: malloc (vg_replace_malloc.c:299) ==29943== by 0x518FA79: asCContext::ExecuteNext() (as_context.cpp:2710) ==29943== by 0x519011C: asCContext::Execute() (as_context.cpp:1324) ==29943== by 0x50296FC: Leviathan::ScriptRunResult<int> Leviathan::ScriptExecutor::RunScriptMethod<int, Leviathan::GenericEvent*&>(Leviathan::ScriptRunningSetup&, asIScriptFunction*, void*, Leviathan::GenericEvent*&) (ScriptExecutor.h:196) ==29943== by 0x502BF2A: non-virtual thunk to Leviathan::Script::EventListener::OnGenericEvent(Leviathan::GenericEvent*) (new_allocator.h:125) ==29943== by 0x50724CC: Leviathan::EventHandler::CallEvent(Leviathan::GenericEvent*) (EventHandler.cpp:65) ==29943== by 0x50608DA: CallEvent (EventHandler.h:38) ==29943== by 0x50608DA: Leviathan::GUI::View::OnProcessMessageReceived(scoped_refptr<CefBrowser>, cef_process_id_t, scoped_refptr<CefProcessMessage>) (GuiView.cpp:860) ==29943== by 0x51328D6: (anonymous namespace)::client_on_process_message_received(_cef_client_t*, _cef_browser_t*, cef_process_id_t, _cef_process_message_t*) (client_cpptoc.cc:264) ==29943== by 0x77EC397: ??? (in /home/hhyyrylainen/Projects/thrive/build/bin/lib/libcef.so) ==29943== by 0x93A7639: ??? (in /home/hhyyrylainen/Projects/thrive/build/bin/lib/libcef.so) ==29943== by 0x93A747D: ??? (in /home/hhyyrylainen/Projects/thrive/build/bin/lib/libcef.so) ==29943== by 0x93A6AA9: ??? (in /home/hhyyrylainen/Projects/thrive/build/bin/lib/libcef.so) After looking for a minimal example that would cause an issue here, I think I got it (this doesn't lead to the same error, though): class Organelle{ } class PlacedOrganelle{ PlacedOrganelle(Organelle@ organelle) { @this.organelle = organelle; } Organelle@ organelle; } void RunTest() { PlacedOrganelle@ organelle = PlacedOrganelle(Organelle()); dictionary data; // This alternative works // @data["organelle"] = organelle; // This causes errors data["organelle"] = organelle; PlacedOrganelle@ organelle2 = cast<PlacedOrganelle>(data["organelle"]); } The error that I get with that is: [SCRIPT] [ERROR] (0, 0) : Failed in call to function 'CreateScriptObject' (Code: asNO_FUNCTION, -6) And it goes away if I add "@" to the assignment into the dictionary. This same thing also fixes my full application so I think this is the same error in both even if the behavior is different. Tested with revision 2547. I tried updating to see if there was a fix (I'd like to get a compile error with the incorrect code), but revision 2557 fails to compile with (this error repeats quite a few times): In file included from /home/hhyyrylainen/Projects/Leviathan/build/ThirdParty/include/add_on/scriptmath/scriptmathcomplex.h:6, from /home/hhyyrylainen/Projects/Leviathan/build/ThirdParty/include/add_on/scriptmath/scriptmathcomplex.cpp:5: /home/hhyyrylainen/Projects/Leviathan/build/ThirdParty/include/add_on/scriptmath/scriptmathcomplex.cpp: Funktio ”void RegisterScriptMathComplex_Native(asIScriptEngine*)”: /home/hhyyrylainen/Projects/Leviathan/build/ThirdParty/include/angelscript.h:421:62: virhe: cast from ”float*” to ”int” loses precision [-fpermissive] #define asOFFSET(s,m) ((int)(&reinterpret_cast<s*>(100000)->m)-100000) ^ /home/hhyyrylainen/Projects/Leviathan/build/ThirdParty/include/add_on/scriptmath/scriptmathcomplex.cpp:177:59: huom: in expansion of macro ”asOFFSET” r = engine->RegisterObjectProperty("complex", "float r", asOFFSET(Complex, r)); assert( r >= 0 ); ^~~~~~~~ /home/hhyyrylainen/Projects/Leviathan/build/ThirdParty/include/angelscript.h:421:62: virhe: cast from ”float*” to ”int” loses precision [-fpermissive] #define asOFFSET(s,m) ((int)(&reinterpret_cast<s*>(100000)->m)-100000) ^ /home/hhyyrylainen/Projects/Leviathan/build/ThirdParty/include/add_on/scriptmath/scriptmathcomplex.cpp:178:59: huom: in expansion of macro ”asOFFSET” r = engine->RegisterObjectProperty("complex", "float i", asOFFSET(Complex, i)); assert( r >= 0 ); ^~~~~~~~ I'm using "gcc (GCC) 8.2.1 20181011 (Red Hat 8.2.1-4)"
  3. Oh my god, I'm blind. The method actually has a return type of 'void' not 'Float3'. I guess this is what I get for copy-pasting the method registrations and forgetting to check the return types. This is the correct binding: if(engine->RegisterObjectMethod("Physics", "void ClearVelocity() const", asMETHOD(Physics, ClearVelocity), asCALL_THISCALL) < 0) { ANGELSCRIPT_REGISTERFAIL; } Thank you for the help.
  4. Hi, I have been trying to track down a crash in my game and I think I have narrowed it down to `X64_CallFunction` in `as_callfunc_x64_gcc.cpp`. The function `CallSystemFunction` (above in the callstack) is given the object as `(void *) 0x559ee40` but when my native function is called (it is a member function) I get `(Leviathan::Physics * const) 0x565ff08` which is invalid as when I inspect the members they are garbage. But if I try `*(Leviathan::Physics * const) 0x559ee40` that has the correct values. So AngelScript does something to the object pointer. Additionally if I change the registration to use asCALL_GENERIC the issue goes away and my function is given the right `this` pointer. Other member functions on that type work fine. For some reason it is just this one. // This crashes if(engine->RegisterObjectMethod("Physics", "Float3 ClearVelocity() const", asMETHOD(Physics, ClearVelocity), asCALL_THISCALL) < 0) { ANGELSCRIPT_REGISTERFAIL; } // This doesn't // if(engine->RegisterObjectMethod("Physics", "Float3 ClearVelocity() const", // WRAP_MFN(Physics, ClearVelocity), asCALL_GENERIC) < 0) { // ANGELSCRIPT_REGISTERFAIL; // } And here is a callstack of the crash: 0 in Leviathan::Physics::ClearVelocity() of /home/hhyyrylainen/Projects/Leviathan/Engine/Entities/Components.cpp:369 1 in X64_CallFunction of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_callfunc_x64_gcc.cpp:74 2 in CallSystemFunctionNative of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_callfunc_x64_gcc.cpp:468 3 in CallSystemFunction(int, asCContext*) of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_callfunc.cpp:730 4 in asCContext::ExecuteNext of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_context.cpp:2557 5 in asCContext::Execute() of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_context.cpp:1324 6 in Leviathan::ScriptExecutor::RunScript<void, thrive::CellStageWorld*> of /usr/include/c++/8/ext/atomicity.h:96 7 in Leviathan::ScriptExecutor::RunScript<void, thrive::CellStageWorld*> of /home/hhyyrylainen/Projects/thrive/ThirdParty/Leviathan/Engine/Script/ScriptExecutor.h:86 8 in Leviathan::GameModule::ExecuteOnModule<void, thrive::CellStageWorld*> of /home/hhyyrylainen/Projects/thrive/ThirdParty/Leviathan/Engine/Addons/GameModule.h:63 9 in thrive::ThriveGame::startNewGame() of /home/hhyyrylainen/Projects/thrive/src/ThriveGame.cpp:329 10 in thrive::ThriveJSMessageHandler::OnProcessMessageReceived(scoped_refptr<CefBrowser>, cef_process_id_t, scoped_refptr<CefProcessMessage>) of /home/hhyyrylainen/Projects/thrive/src/thrive_js_interface.cpp:142 11 in Leviathan::GlobalCEFHandler::HandleCustomExtensionProcessMessage(scoped_refptr<CefBrowser>, cef_process_id_t, scoped_refptr<CefProcessMessage>) of /home/hhyyrylainen/Projects/Leviathan/Engine/GlobalCEFHandler.cpp:282 12 in Leviathan::GUI::View::OnProcessMessageReceived(scoped_refptr<CefBrowser>, cef_process_id_t, scoped_refptr<CefProcessMessage>) of /home/hhyyrylainen/Projects/Leviathan/Engine/GUI/GuiView.cpp:634 13 in (anonymous namespace)::client_on_process_message_received of /home/hhyyrylainen/Projects/Leviathan/ThirdParty/CEF/libcef_dll/cpptoc/client_cpptoc.cc:269 14 in OnProcessMessageReceived of ../../cef/libcef_dll/ctocpp/client_ctocpp.cc:237 15 in OnRequest of ../../cef/libcef/browser/browser_host_impl.cc:3006 16 in DispatchToMethodImpl<CefBrowserHostImpl*, void (CefBrowserHostImpl::*)(Cef_Request_Params const&), std::__1::tuple<Cef_Request_Params>, 0> of ../../base/tuple.h:52 17 in DispatchToMethod<CefBrowserHostImpl*, void (CefBrowserHostImpl::*)(Cef_Request_Params const&), std::__1::tuple<Cef_Request_Params> > of ../../base/tuple.h:60 18 in DispatchToMethod<CefBrowserHostImpl, void (CefBrowserHostImpl::*)(Cef_Request_Params const&), void, std::__1::tuple<Cef_Request_Params> > of ../../ipc/ipc_message_templates.h:51 19 in Dispatch<CefBrowserHostImpl, CefBrowserHostImpl, void, void (CefBrowserHostImpl::*)(Cef_Request_Params const&)> of ../../ipc/ipc_message_templates.h:146 20 in OnMessageReceived of ../../cef/libcef/browser/browser_host_impl.cc:2849 21 in OnMessageReceived of ../../content/browser/web_contents/web_contents_impl.cc:791 22 in OnMessageReceived of ../../content/browser/renderer_host/render_view_host_impl.cc:739 23 in OnMessageReceived of ../../content/browser/renderer_host/render_widget_host_impl.cc:594 24 in OnDispatchMessage of ../../ipc/ipc_channel_proxy.cc:320 25 in Run of ../../base/callback.h:65 26 in RunTask of ../../base/debug/task_annotator.cc:55 27 in RunTask of ../../base/message_loop/message_loop.cc:399 28 in DeferOrRunPendingTask of ../../base/message_loop/message_loop.cc:411 29 in DoWork of ../../base/message_loop/message_loop.cc:455 30 in base::MessagePumpGlib::Run(base::MessagePump::Delegate*) of ../../base/message_loop/message_pump_glib.cc:309 31 in Run of ../../base/run_loop.cc:130 32 in RunUntilIdle of ../../base/run_loop.cc:143 33 in CefBrowserMessageLoop::DoMessageLoopIteration() of ../../cef/libcef/browser/browser_message_loop.cc:116 34 in Leviathan::GlobalCEFHandler::DoCEFMessageLoopWork() of /home/hhyyrylainen/Projects/Leviathan/Engine/GlobalCEFHandler.cpp:181 35 in Leviathan::Engine::MessagePump() of /home/hhyyrylainen/Projects/Leviathan/Engine/Engine.cpp:657 36 in Leviathan::LeviathanApplication::RunMessageLoop() of /home/hhyyrylainen/Projects/Leviathan/Engine/Application/Application.cpp:124 37 in main of /home/hhyyrylainen/Projects/thrive/src/main.cpp:219 38 in __libc_start_main of /lib64/libc.so.6 39 in _start of /home/hhyyrylainen/Projects/thrive/src/main.cpp:172 I am using svn revision 2547 (I used 2482 before but I just updated to confirm that this hasn't been fixed). My compiler is 'gcc (GCC) 8.1.1 20180712 (Red Hat 8.1.1-5)' This issue also seems to be Linux specific as other people also working on the same game on Windows don't have a crash in this function (I haven't personally tested on Windows). I can provide a core dump of the invalid passed this pointer if that would help.
  5. Boost113

    Compiler error in svn trunk on linux

    I don't have experience with mingw on windows but I've used cygwin and (I just checked again from the documentation) that sets the UNIX flag in cmake. Not sure if a check for `NOT MSVC` would be better, then.
  6. Hi, I tried compiling the latest trunk version (2481). With gcc on linux and I got this error (I'm using cmake): Building CXX object CMakeFiles/angelscript.dir/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp.o /usr/bin/c++ -D-fPIC -DANGELSCRIPT_EXPORT -D_LIB -I/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/projects/cmake/../../include -O2 -g -DNDEBUG -o CMakeFiles/angelscript.dir/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp.o -c /home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp <komentorivi>:0:1: virhe: makrojen nimien on oltava tunnisteita make[2]: *** [CMakeFiles/angelscript.dir/build.make:63: CMakeFiles/angelscript.dir/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/sdk/angelscript/source/as_atomic.cpp.o] Virhe 1 make[2]: Poistutaan hakemistosta ”/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/build” make[1]: *** [CMakeFiles/Makefile2:68: CMakeFiles/angelscript.dir/all] Virhe 2 make[1]: Poistutaan hakemistosta ”/home/hhyyrylainen/Projects/Leviathan/ThirdParty/angelscript/build” make: *** [Makefile:130: all] Virhe 2 The interesting part here is `-D-fPIC` which is the cause of the error. I was able to fix this by changing this configuration `target_compile_definitions(${ANGELSCRIPT_LIBRARY_NAME} PRIVATE -fPIC)` to this: `target_compile_options(${ANGELSCRIPT_LIBRARY_NAME} PRIVATE -fPIC)`. I changed the compile definition to be compile option which correctly no longer adds `-D` in front of `-fPIC`. I Also added a check to the if condition that contains that setting to include check for UNIX as I think as it currently is it won't work on windows (I also use cmake with angelscript on windows, but didn't test that yet). I included a diff of the change. patch.diff
  7. I don't think that's completely necessary as (AFAIK) none of the changes I did to AngelScript depend on C++11. But that sample callback needs C++11 to work correctly. So there's probably not much use for the callback without C++11 support, but the library should compile fine, it would just be have an extra useless feature. I'd like to see this feature added to the svn version as soon as possible as I don't mid switching to a newer revision to use this (I've been using the svn latest branch for a long time now). So when the next actual release doesn't matter that much to me.
  8. I was initially going to argue that any self-respecting c++ library will use std::exception as a base type for all of their exceptions. But after cooling down for a while I can definitely see that allowing that might open the gates for requests of other exception types and a generic callback gives more flexibility. After looking at solokiller's suggestion I decided to attempt to implement such a callback. And I got it working. I attached a diff of my changes. I basically duplicated what asCContext::SetExceptionCallback does to make a new "Translate exception" callback, which I placed into a new method "HandleExceptionHappened", I had to add this as c++ exceptions were caught in multiple places. So now setting that callback to something like this: void ScriptTranslateExceptionCallback(asIScriptContext* context, void* userdata) { try { std::rethrow_exception(std::current_exception()); } catch(const std::exception& e) { context->SetException( (std::string("Caught application exception: ") + e.what()).c_str()); } } ctx->SetTranslateExceptionCallback(asFUNCTION(ScriptTranslateExceptionCallback), nullptr, asCALL_CDECL); Results in nicer script exception messages: "Caught application exception: Testing custom messages" as_exception_translate.diff
  9. That would not work for me as I extensively use third party libraries that report errors as exceptions, that are derived from std::exception. I think that this feature will only be useful if the exceptions that the script context can read messages from don't need to derive from or now about AngelScript types.
  10. I'd like to be able to read the messages from exceptions that AngelScript catches without the hassle of using gdb with break on throw. So I suggest adding the following code to as_context.cpp before the "catch (...)" part: catch (const std::exception &e) { SetExpection((TXT_EXCEPTION_CAUGHT ", with message: " + std::string(e.what()))c._str()); } This was the only relevant link to this that I found: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_cpp_exceptions.html But as almost all of my methods exposed to AngelScripts can throw exceptions it's not really possible (and probably bad for performance) to wrap them in extra wrappers that are there to just catch exception messages. I'm using Last Changed Rev: 2457 so hopefully this hasn't been done after that.
  11. Boost113

    Segmentation fault with dictionary retrieve to auto

    I'm using version 2.32.0 from svn: URL: http://svn.code.sf.net/p/angelscript/code/tags/2.32.0 Relative URL: ^/tags/2.32.0 Repository Root: http://svn.code.sf.net/p/angelscript/code Repository UUID: 404ce1b2-830e-0410-a2e2-b09542c77caf Revision: 2463 and I haven't made any changes to the add-ons
  12. Boost113

    Segmentation fault with dictionary retrieve to auto

    After going back in git history and playing around a bit I got this function to cause the crash: void setupSpecies(CellStageWorld@ world){ auto keys = STARTER_MICROBES.getKeys(); for(uint i = 0; i < keys.length(); ++i){ const string name = keys[i]; MicrobeTemplate@ data = cast<MicrobeTemplate@>(STARTER_MICROBES[name]); ObjectID speciesEntity = world.CreateEntity(); SpeciesComponent@ speciesComponent = world.Create_SpeciesComponent(speciesEntity, name); speciesComponent.avgCompoundAmounts = dictionary(); ProcessorComponent@ processorComponent = world.Create_ProcessorComponent( speciesEntity); speciesComponent.colour = data.colour; // iterates over all compounds, and sets amounts and priorities uint64 compoundCount = SimulationParameters::compoundRegistry().getSize(); for(uint a = 0; a < compoundCount; ++a){ auto compound = SimulationParameters::compoundRegistry().getTypeData(a); // int compoundData; // bool valid = data.compounds.get(compound.internalName, compoundData); auto compoundData = data.compounds[compound.internalName]; if(compoundData !is null){ int amount = compoundData.amount; speciesComponent.avgCompoundAmounts[formatUint(a)] = amount; } } } } Changing around the commented lines to this stops the crashing: int compoundData; bool valid = data.compounds.get(compound.internalName, compoundData); // auto compoundData = data.compounds[compound.internalName]; From my testing it seems that this line is also important in making the crash happen: "if(compoundData !is null){" That uses quite a few other classes and registered application functions so if they are needed for this to crash I can post a link to a tag in a repository with all the files.
  13. Hi, When I have this line in a script: `auto compoundData = data.compounds[compound.internalName];` I get a segmentation fault. Here: 0 in asCArray<int>::GetLength() const of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 1 in asCCompiler::CompileOverloadedDualOperator2(asCScriptNode*, char const*, asCExprContext*, asCExprContext*, bool, asCExprContext*, bool, asCDataType const&) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 2 in asCCompiler::CompileOperatorOnHandles(asCScriptNode*, asCExprContext*, asCExprContext*, asCExprContext*, eTokenType) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 3 in asCCompiler::CompileOperator(asCScriptNode*, asCExprContext*, asCExprContext*, asCExprContext*, eTokenType, bool) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 4 in asCCompiler::CompilePostFixExpression(asCArray<asCScriptNode*>*, asCExprContext*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 5 in asCCompiler::CompileExpression(asCScriptNode*, asCExprContext*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 6 in asCCompiler::CompileCondition(asCScriptNode*, asCExprContext*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 7 in asCCompiler::CompileAssignment(asCScriptNode*, asCExprContext*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 8 in asCCompiler::CompileIfStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 9 in asCCompiler::CompileStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 10 in asCCompiler::CompileStatementBlock(asCScriptNode*, bool, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 11 in asCCompiler::CompileStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 12 in asCCompiler::CompileForStatement(asCScriptNode*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 13 in asCCompiler::CompileStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 14 in asCCompiler::CompileStatementBlock(asCScriptNode*, bool, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 15 in asCCompiler::CompileStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 16 in asCCompiler::CompileForStatement(asCScriptNode*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 17 in asCCompiler::CompileStatement(asCScriptNode*, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 18 in asCCompiler::CompileStatementBlock(asCScriptNode*, bool, bool*, asCByteCode*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 19 in asCCompiler::CompileFunction(asCBuilder*, asCScriptCode*, asCArray<asCString>&, asCScriptNode*, asCScriptFunction*, sClassDeclaration*) of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 20 in asCBuilder::CompileFunctions() of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 21 in asCBuilder::Build() of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 22 in asCModule::Build() of /home/hhyyrylainen/Projects/thrive/build/bin/libEngine.so 23 in CScriptBuilder::Build of /home/hhyyrylainen/Projects/leviathan/build/ThirdParty/include/add_on/scriptbuilder/scriptbuilder.cpp:520 24 in CScriptBuilder::BuildModule of /home/hhyyrylainen/Projects/leviathan/build/ThirdParty/include/add_on/scriptbuilder/scriptbuilder.cpp:117 If I change the line to (change auto to int): `int compoundData = data.compounds[compound.internalName];` I get an compile error "Can't implicitly convert from 'dictionaryValue' to 'int'" instead of a segmentation fault. I know that the above example shouldn't compile either, but it would be nice to have an error message instead of a crash.
  14. This check in some of the add-ons: #ifdef AS_CAN_USE_CPP11 #include <chrono> #else #error Sorry, this requires C++11 which your compiler doesn't appear to support #endif Causes warnings about there being a missing ' character: /home/hhyyrylainen/Projects/leviathan/libraries/include/add_on/datetime/datetime.h:12:60: varoitus: päättävä merkki ' puuttuu #error Sorry, this requires C++11 which your compiler doesn't appear to support ^ This is nothing major, but it does cause annoying warnings when rebuilding files that include the add-on headers.
  15. Boost113

    GCC 5.1 Deprecated warnings

    That fixed it, thanks.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!