Page MenuHomeWildfire Games

Fix Collada build on VS2015
ClosedPublic

Authored by Stan on Dec 16 2019, 4:40 PM.

Details

Summary

Currently if you build Fcollada with VS2015 it segfaults with the following call stack. That's because the field malloc and free are not for some reason properly initialized anymore.

https://pastebin.com/4p3hfQyY

Test Plan

Do the same, but apply the patch notice it doesn't crash anymore. Check if the models are still working properly, (not glitches, missing anims, error messages)

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Stan created this revision.Dec 16 2019, 4:40 PM
Herald added 1 blocking reviewer(s): Itms. · View Herald TranscriptDec 16 2019, 4:40 PM

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1290/display/redirect

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/774/display/redirect

Stan added a comment.Dec 16 2019, 7:13 PM

Patch won't apply cause the file has non native EOL :/

Stan updated this revision to Diff 10619.Dec 16 2019, 7:21 PM

Fix path

Build failure - The Moirai have given mortals hearts that can endure.

Link to build: https://jenkins.wildfiregames.com/job/docker-differential/1291/display/redirect

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/vs2015-differential/775/display/redirect

Stan edited the test plan for this revision. (Show Details)Jan 3 2020, 7:32 PM
lyv added a subscriber: lyv.Nov 24 2020, 8:23 AM

I am not sure this functionality should be totally removed. I went with what basically boils down to: if (!alloc) setAlloc(malloc).

I am fairly sure this a VS bug that is preventing them from being initialized, maybe because its in a namespace, being built as a DLL, I don't know....
This behaviour is certainly not in the standard, so what else could it be.

Pick your poison I guess.

Looks like Static Initialisation Order Fiasco to me.
The stack-trace above implies that when it loads the DLL, and initialises the static variables, it crashes when trying to allocate. That makes sense if the variables it initialises are being initialised _before_ the allocation functions. In which case going for an if (nullptr) { something } is probably the better call (though it does seem like the SetAllocationFunctionsis never used, so it's probably irrelevant).

Stan updated this revision to Diff 14173.Nov 24 2020, 10:59 AM

Alternate fix based on feeback of wraitii and smiley

Successful build - Chance fights ever on the side of the prudent.

builderr-debug-macos.txt
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:154:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
../../../source/third_party/fmt/format.cpp:145:7: warning: '_POSIX_C_SOURCE' is not defined, evaluates to 0 [-Wundef]
#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || (defined(__ANDROID__) && __ANDROID__)
      ^
../../../source/third_party/fmt/format.cpp:145:37: warning: '_XOPEN_SOURCE' is not defined, evaluates to 0 [-Wundef]
#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || (defined(__ANDROID__) && __ANDROID__)
                                    ^
2 warnings generated.
ld: warning: direct access in function 'RLMgCallback(mg_event, mg_connection*, mg_request_info const*)' from file 'obj/pyrogenesis_Debug/main.o' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'RLMgCallback(mg_event, mg_connection*, mg_request_info const*)' from file 'obj/pyrogenesis_Debug/main.o' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'tinygettext::POParser::parse()' from file '../../../binaries/system/libtinygettext_dbg.a(po_parser.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'JSI_Network::StartNetworkJoin(ScriptInterface::CmptPrivate*, CStrW const&, CStr8 const&, unsigned short, bool, CStr8 const&)' from file '../../../binaries/system/libengine_dbg.a(JSInterface_Network.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::Find(CStr8 const&) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::ReverseFind(CStr8 const&) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::AfterLast(CStr8 const&, unsigned long) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::BeforeLast(CStr8 const&, unsigned long) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::AfterFirst(CStr8 const&, unsigned long) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::BeforeFirst(CStr8 const&, unsigned long) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::Remove(CStr8 const&)' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::Replace(CStr8 const&, CStr8 const&)' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CTemplateLoader::LoadTemplateFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)' from file '../../../binaries/system/libengine_dbg.a(TemplateLoader.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'SplitExts(char const*)' from file '../../../binaries/system/libengine_dbg.a(Util.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'SplitExts(char const*)' from file '../../../binaries/system/libengine_dbg.a(Util.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'COList::HandleAdditionalChildren(XMBElement const&, CXeromyces*)' from file '../../../binaries/system/libgui_dbg.a(COList.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.
ld: warning: direct access in function 'TestCLogger::ParseOutput()' from file 'obj/test_Debug/test_CLogger.o' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CxxTest::XmlFormatter::enterSuite(CxxTest::SuiteDescription const&)' from file 'obj/test_Debug/test_root.o' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'ts_str_contains(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)' from file 'obj/test_Debug/test_setup.o' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'tinygettext::POParser::parse()' from file '../../../binaries/system/libtinygettext_dbg.a(po_parser.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'JSI_Network::StartNetworkJoin(ScriptInterface::CmptPrivate*, CStrW const&, CStr8 const&, unsigned short, bool, CStr8 const&)' from file '../../../binaries/system/libengine_dbg.a(JSInterface_Network.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::Find(CStr8 const&) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::ReverseFind(CStr8 const&) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::AfterLast(CStr8 const&, unsigned long) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::BeforeLast(CStr8 const&, unsigned long) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::AfterFirst(CStr8 const&, unsigned long) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::BeforeFirst(CStr8 const&, unsigned long) const' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::Remove(CStr8 const&)' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CStr8::Replace(CStr8 const&, CStr8 const&)' from file '../../../binaries/system/libengine_dbg.a(CStr.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'CTemplateLoader::LoadTemplateFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int)' from file '../../../binaries/system/libengine_dbg.a(TemplateLoader.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'SplitExts(char const*)' from file '../../../binaries/system/libengine_dbg.a(Util.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'SplitExts(char const*)' from file '../../../binaries/system/libengine_dbg.a(Util.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'COList::HandleAdditionalChildren(XMBElement const&, CXeromyces*)' from file '../../../binaries/system/libgui_dbg.a(COList.o)' to global weak symbol 'std::__1::char_traits<char>::eq(char, char)' from file '../../../libraries/osx/gloox/lib/libgloox.a(clientbase.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
builderr-release-macos.txt
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libnetwork.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libtinygettext.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libtinygettext.a(tinygettext.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/liblobby.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libglooxwrapper.a(precompiled.o) has no symbols
../../../source/simulation2/scripting/JSInterface_Simulation.cpp:154:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CFixedVector2D(-halfSize.X, -halfSize.Y),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libsimulation2.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libscriptinterface.a(precompiled.o) has no symbols
../../../source/third_party/fmt/format.cpp:145:7: warning: '_POSIX_C_SOURCE' is not defined, evaluates to 0 [-Wundef]
#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || (defined(__ANDROID__) && __ANDROID__)
      ^
../../../source/third_party/fmt/format.cpp:145:37: warning: '_XOPEN_SOURCE' is not defined, evaluates to 0 [-Wundef]
#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || (defined(__ANDROID__) && __ANDROID__)
                                    ^
2 warnings generated.
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libengine.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgraphics.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libatlas.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/libgui.a(precompiled.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/liblowlevel.a(dbghelp.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/liblowlevel.a(file_stats.o) has no symbols
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: ../../../binaries/system/liblowlevel.a(vfs_path.o) has no symbols
In file included from ../../../source/graphics/tests/test_Camera.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/graphics/tests/test_Camera.h:168:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        CVector3D(-101.0f, -101.0f, 101.0f),
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
In file included from ../../../source/simulation2/tests/test_SerializeTemplates.cpp:17:
/Users/wfg/Jenkins/workspace/macos-differential/source/simulation2/tests/test_SerializeTemplates.h:39:4: warning: suggest braces around initialization of subobject [-Wmissing-braces]
                        3, 0, 1, 4, 1, 5
                        ^~~~~~~~~~~~~~~~
                        {               }
1 warning generated.

Link to build: https://jenkins.wildfiregames.com/job/macos-differential/2100/display/redirect

wraitii accepted this revision.Nov 24 2020, 11:21 AM

Looks good to me. I hadn't realised that the crash was in Fcollada static stuff, which definitely points toward SIOF. Works with the amended changes so far as we can tell.

I prefer the "if" approach as it keeps the functionality, ought to make no difference.

This revision was not accepted when it landed; it landed in state Needs Review.Nov 24 2020, 12:07 PM
This revision was automatically updated to reflect the committed changes.
Owners added a subscriber: Restricted Owners Package.Nov 24 2020, 12:07 PM