GameFoundry / bsf

Modern C++14 library for the development of real-time graphical applications
https://www.bsframework.io
MIT License
1.73k stars 194 forks source link

Crash on Startup of Skeletal Animation Example #133

Open cwfitzgerald opened 6 years ago

cwfitzgerald commented 6 years ago

On my Ubuntu system, there is a crash when starting up the Skeletal Animation demo. All the others start fine, though they end with a segfault, that doesn't terribly matter right now (and I will file a separate issue about that). I have attached the crash log provided by the builtin crash handler, as well as the output of AddressSanitizer and the output of glxinfo.

CMake Command:

cmake ../bsfExamples/ -GNinja -DCMAKE_CXX_COMPILER=clang++-6.0 -DCMAKE_C_COMPILER=clang-6.0 -DCMAKE_EXE_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld -DCMAKE_C_FLAGS="-fsanitize=address -fno-omit-frame-pointer" -DCMAKE_CXX_FLAGS="-fsanitize=address -fno-omit-frame-pointer" -DCMAKE_BUILD_TYPE=Debug

Log File: log.html.txt

Output of ASan

Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for 4294967295, skipping unlock
AddressSanitizer:DEADLYSIGNAL
=================================================================
==9660==ERROR: AddressSanitizer: SEGV on unknown address 0x0000cc6e96b9 (pc 0x0000002ffa6c bp 0x7fff22ae78a0 sp 0x7fff22ae7010 T0)
==9660==The signal is caused by a READ memory access.
    #0 0x2ffa6b in __interceptor_strcmp.part.59 (/home/connor/Programming/bsfExamples/bin/x64/Debug/SkeletalAnimation+0x2ffa6b)
    #1 0x7faf53d2205a in fbxsdk::FbxManager::Internal_RegisterFbxClass(char const*, fbxsdk::FbxClassId, fbxsdk::FbxObject* (*)(fbxsdk::FbxManager&, char const*, fbxsdk::FbxObject const*), char const*, char const*) (/home/connor/Programming/bsfExamples/bin/x64/Debug/libbsfFBXImporter.so+0x64b05a)
    #2 0x7faf53d22816 in fbxsdk::FbxManager::ClassInit() (/home/connor/Programming/bsfExamples/bin/x64/Debug/libbsfFBXImporter.so+0x64b816)
    #3 0x7faf53d23cef in fbxsdk::FbxManager::FbxManager() (/home/connor/Programming/bsfExamples/bin/x64/Debug/libbsfFBXImporter.so+0x64ccef)
    #4 0x7faf53d23eea in fbxsdk::FbxManager::Create() (/home/connor/Programming/bsfExamples/bin/x64/Debug/libbsfFBXImporter.so+0x64ceea)
    #5 0x7faf53c03df4 in bs::FBXImporter::startUpSdk(fbxsdk::FbxScene*&) /home/connor/Programming/bsf/Source/Plugins/bsfFBXImporter/BsFBXImporter.cpp:465:17
    #6 0x7faf53c02008 in bs::FBXImporter::importMeshData(bs::Path const&, std::shared_ptr<bs::ImportOptions const>, std::vector<bs::SubMesh, bs::StdAlloc<bs::SubMesh, bs::GenAlloc> >&, std::vector<bs::FBXAnimationClipData, bs::StdAlloc<bs::FBXAnimationClipData, bs::GenAlloc> >&, std::shared_ptr<bs::Skeleton>&, std::shared_ptr<bs::MorphShapes>&) /home/connor/Programming/bsf/Source/Plugins/bsfFBXImporter/BsFBXImporter.cpp:207:8
    #7 0x7faf53c02ef0 in bs::FBXImporter::importAll(bs::Path const&, std::shared_ptr<bs::ImportOptions const>) /home/connor/Programming/bsf/Source/Plugins/bsfFBXImporter/BsFBXImporter.cpp:142:45
    #8 0x7faf6eb5e1ac in bs::Importer::_importAll(bs::Path const&, std::shared_ptr<bs::ImportOptions const>) const /home/connor/Programming/bsf/Source/Foundation/bsfCore/Importer/BsImporter.cpp:149:20
    #9 0x7faf6eb5dd5a in bs::Importer::importAll(bs::Path const&, std::shared_ptr<bs::ImportOptions const>) /home/connor/Programming/bsf/Source/Foundation/bsfCore/Importer/BsImporter.cpp:97:45
    #10 0x369626 in bs::loadAssets() /home/connor/Programming/bsfExamples/Source/SkeletalAnimation/Main.cpp:66:52
    #11 0x36ad5f in main /home/connor/Programming/bsfExamples/Source/SkeletalAnimation/Main.cpp:205:18
    #12 0x7faf6a41e82f in __libc_start_main /build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:291
    #13 0x269028 in _start (/home/connor/Programming/bsfExamples/bin/x64/Debug/SkeletalAnimation+0x269028)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/home/connor/Programming/bsfExamples/bin/x64/Debug/SkeletalAnimation+0x2ffa6b) in __interceptor_strcmp.part.59
==9660==ABORTING
Aborted (core dumped)

GLXInfo: glxinfo.txt

If you need anything else, let me know, thanks for the lovely framework!

BearishSun commented 6 years ago

Hi, thanks for the report.

I've managed to reproduce the issue. The problem happens in FBX SDK, which is a third party library with no source code access so there is not much I can do about it. Updating to latest FBX SDK 2019 doesn't resolve the problem.

The problem only occurs when compiling using Clang, while GCC reports no issues. It's possible it's also some kind of a false positive, as the FBX SDK static library was compiled using GCC.

I can suggest a few options:

cwfitzgerald commented 6 years ago

The problem happens no matter what, this was only a reaction because the program crashed due to a segmentation fault. ASan was just a tool I used to find the problem.

Compiling without clang isn't really preferable due to clang's much better compile times but if its really the only option is manageable I guess. It could also be a problem with lld, I'll poke around and see what combinations of compiler/linker provide.

Connor Fitzgerald Sent from my Phone. Please excuse my brevity.

On May 25, 2018 7:53:52 AM EDT, Marko Pintera notifications@github.com wrote:

Hi, thanks for the report.

I've managed to reproduce the issue. The problem happens in FBX SDK, which is a third party library with no source code access so there is not much I can do about it. Updating to latest FBX SDK 2019 doesn't resolve the problem.

The problem only occurs when compiling using Clang, while GCC reports no issues. It's possible it's also some kind of a false positive, as the FBX SDK static library was compiled using GCC.

I can suggest a few options:

  • Compile using GCC instead of Clang
  • Disable ASAN halt on error to get over the issue, or compile without ASAN completely

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/GameFoundry/bsf/issues/133#issuecomment-392030070

BearishSun commented 6 years ago

Right, that's more serious then - I certainly don't want to drop support for Clang fully. I'll see if I can isolate the problem in a simpler program to ensure FBX SDK is indeed the problem. The only option I can see then is to try linking with the shared object version of the library.

cwfitzgerald commented 6 years ago

So it appears as though the problem lies within my use of lld. I recompiled just now will all the same flags but without lld, and the program started just fine. This would lead me to believe that the segmentation fault is a direct result of the different linking behavior of lld. Not using lld isn't ideal either (it is the provider of LTO under clang and holy hell is it fast), but it is very possible that I could isolate the link action that causes the issue.

I would still like to come to some solution to this problem but at least there is a temporary workaround.

BearishSun commented 6 years ago

Thanks for testing it out. I haven't had a chance to take a closer look yet, but will hopefully this week. If possible I will switch to the shared object version of the FBX library which will likely get rid of the issue - unless you figure out exactly what goes wrong with lld.