thunder icon indicating copy to clipboard operation
thunder copied to clipboard

Engine: BSD: Address SIGSEGV error on Loading / Creating a Project

Open thearchivalone opened this issue 1 year ago • 15 comments

valgrind-log.zip

Description

The editor partially loads the project and then crashes after a few seconds. It immediately crashes after project creation.

Prerequisites

Was on the project selection screen waiting to open a project.

Steps to Reproduce

  1. Build latest source code with CMake.
  2. Install to the SDK build directory using gmake install
  3. Run WorldEditor from inside of install-root/sdk/2024.2/freebsd/x86/bin/ directory
  4. Load up or create new project.

Expected behavior:

Full editor loads.

Actual behavior:

Crashes while loading editor and engine.

Reproducibility:

Consistently.

Versions

Version

Additional Information

I decided to run both gdb and Valgrind to get to the bottom of this. Attached is the Valgrind log.

Note the Invalid write of size 8 on line 400 and then the Address 0x70 is not stack'd on line 413. There's other errors but MaterialInstance::setTransform is the crashing function in both debugger applications.

thearchivalone avatar Jul 03 '24 06:07 thearchivalone

I'm not fully sure how to fix this yet but this may be related to the crashes others have been running into.

thearchivalone avatar Jul 03 '24 06:07 thearchivalone

Seems like the issue in Renderable::setMaterialsList some materials was nullptr and have not created an instance for it. Which leads to nullptr exception

eprikazchikov avatar Jul 03 '24 06:07 eprikazchikov

Have added a checker. But I assume some standard resources was not installed properly because of CMake build

eprikazchikov avatar Jul 03 '24 07:07 eprikazchikov

That's part of why I might attempt to build Qt from source. Many of the libraries (especially the standard ones outside of the current build system) are ports of the Linux ones. I noticed several Qt library related errors in that log

thearchivalone avatar Jul 03 '24 13:07 thearchivalone

it's not related Qt. Please check resources dir in SDK

eprikazchikov avatar Jul 03 '24 13:07 eprikazchikov

Running gmake install produces this:

CMake Error at build/cmake_install.cmake:45 (file):
  file INSTALL cannot find "/plugins/imageformats": No such file or
  directory.
Call Stack (most recent call first):
  cmake_install.cmake:48 (include)

and then it complains about not having a local Qt installation and errors out with that too if I comment this out in build/cmake_install.cmake

thearchivalone avatar Jul 03 '24 14:07 thearchivalone

it's CMake issues imageformats is directory not file

eprikazchikov avatar Jul 03 '24 14:07 eprikazchikov

There's no .embedded folder so it throws this also when loading: [ FileIO ] Can't open file .embedded/DefaultMesh.shader

thearchivalone avatar Jul 03 '24 14:07 thearchivalone

Thank you for your patience, by the way. We got this. I implemented your current commit manually and still getting a crash but also it loaded a bit further. Debugging now

thearchivalone avatar Jul 03 '24 14:07 thearchivalone

.embedded is "virtual" directory. it's means this resource located NOT in project directory. It has many inputs most of them in "resources" directory. Check SDK build from the archive which I mentioned yesterday

eprikazchikov avatar Jul 03 '24 14:07 eprikazchikov

It's not in the Linux one. I'll try from the Windows archive.

thearchivalone avatar Jul 03 '24 14:07 thearchivalone

image

eprikazchikov avatar Jul 03 '24 14:07 eprikazchikov

I mean the .embedded doesn't exist. Should it? I've already copied that folder from the Linux archive. Copying from the Windows one to see if there's a difference

thearchivalone avatar Jul 03 '24 14:07 thearchivalone

.embedded doesn't exist on disk. It's just alias which points to files in "resources" directory. I have added it to separate game project resources from basic ones.

eprikazchikov avatar Jul 03 '24 14:07 eprikazchikov

Yeah, platform release doesn't matter in this case. It's in the code.

thearchivalone avatar Jul 03 '24 14:07 thearchivalone

Implementing your fix and adding a couple more checks, I was able to get this stacktrace with gdb:

0x0000000823e8c516 in PipelineContext::draw(Camera*) ()
   from /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/../lib/libengine-editor.so
(gdb) backtrace 
#0  0x0000000823e8c516 in PipelineContext::draw(Camera*) ()
    at /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/../lib/libengine-editor.so
#1  0x0000000823ef3246 in RenderSystem::update(World*) ()
    at /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/../lib/libengine-editor.so
#2  0x000000089dad2358 in RenderGLSystem::update(World*) ()
    at /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/plugins/librendergl-editor.so
#3  0x0000000823ef370a in RenderSystem::renderOffscreen(World*, int, int) ()
    at /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/../lib/libengine-editor.so
#4  0x000000089dad23cb in RenderGLSystem::renderOffscreen(World*, int, int) ()
    at /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/plugins/librendergl-editor.so
#5  0x000000000032c6d1 in IconRender::render(QString const&, QString const&) ()
#6  0x0000000000332282 in ImportQueue::onImportFinished() ()
#7  0x0000000000333f2b in QtPrivate::FunctorCall<QtPrivate::IndexesList<>, QtPrivate::List<>, void, void (ImportQueue::*)()>::call(void (ImportQueue::*)(), ImportQueue*, void**) ()
#8  0x0000000000333e9d in void QtPrivate::FunctionPointer<void (ImportQueue::*)()>::call<QtPrivate::List<>, void>(void (ImportQueue::*)(), ImportQueue*, void**) ()
#9  0x0000000000333de2 in QtPrivate::QSlotObject<void (ImportQueue::*)(), QtPrivate::List<>, void>::impl(int, QtPrivate::QSlotObjectBase*, QObject*, void**, bool*) ()
#10 0x000000082e656672 in ??? () at /usr/local/lib/qt5/libQt5Core.so.5
#11 0x0000000823f19fd5 in AssetManager::importFinished() ()
    at /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/../lib/libengine-editor.so
#12 0x0000000823e03a5f in AssetManager::onPerform() ()
    at /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/../lib/libengine-editor.so
#13 0x0000000823f19b08 in AssetManager::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) ()
    at /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/../lib/libengine-editor.so
#14 0x000000082e656736 in ??? () at /usr/local/lib/qt5/libQt5Core.so.5
#15 0x000000082e65b803 in QTimer::timerEvent(QTimerEvent*) () at /usr/local/lib/qt5/libQt5Core.so.5
#16 0x000000082e64b5b7 in QObject::event(QEvent*) () at /usr/local/lib/qt5/libQt5Core.so.5
#17 0x0000000827c99b43 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
    at /usr/local/lib/qt5/libQt5Widgets.so.5
#18 0x0000000827c9aeee in QApplication::notify(QObject*, QEvent*) ()
    at /usr/local/lib/qt5/libQt5Widgets.so.5
#19 0x000000082e622df1 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
    at /usr/local/lib/qt5/libQt5Core.so.5
#20 0x000000082e6748b4 in QTimerInfoList::activateTimers() () at /usr/local/lib/qt5/libQt5Core.so.5
#21 0x000000082e676381 in ??? () at /usr/local/lib/qt5/libQt5Core.so.5
#22 0x0000000837a13ee1 in ??? () at /usr/local/lib/libglib-2.0.so.0
#23 0x0000000837a1428f in ??? () at /usr/local/lib/libglib-2.0.so.0
#24 0x0000000837a14326 in g_main_context_iteration () at /usr/local/lib/libglib-2.0.so.0
#25 0x000000082e675915 in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () at /usr/local/lib/qt5/libQt5Core.so.5
#26 0x000000082e61f786 in QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) ()
    at /usr/local/lib/qt5/libQt5Core.so.5
#27 0x000000082e623471 in QCoreApplication::exec() () at /usr/local/lib/qt5/libQt5Core.so.5
#28 0x000000000030d5d4 in main ()

thearchivalone avatar Jul 03 '24 15:07 thearchivalone

I can assume pipeline was not fully loaded. Could you check if pipeline tools plugin loaded? Pipeline is a special game resource which describes the order to render image and tasks were needed to render it.

eprikazchikov avatar Jul 03 '24 16:07 eprikazchikov

 [PluginManager] Can't load plugin: /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/plugins/libpipelinetools.so
 [PluginManager] Can't load plugin: /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/plugins/libshadertools.so
 [PluginManager] Can't load plugin: /home/brad/git/thunder-build/install-root/sdk/2024.2/freebsd/x86/bin/plugins/libmotiontools.so

Right on the money.

thearchivalone avatar Jul 03 '24 16:07 thearchivalone

When I get off of work, I found some more places some checks can be added. Probably won’t fully solve the underlying problem but your suggestions have given me a direction on what to look for while I have downtime at work.

thearchivalone avatar Jul 03 '24 17:07 thearchivalone

I think you should check dependencies for this plugins using ldd or analog on BSD platform. They all uses grapheditor module

eprikazchikov avatar Jul 03 '24 17:07 eprikazchikov

Got it. I’ll still implement those checks locally since they won’t harm anything. There’s no library linkage errors left for the builds so far but I can recheck after work.

My assumptions are it’s the platform and system libraries first over your code for the same reasons you’ll suggest it’s directly related to your code and your build system. I’m enjoying working on this, to be honest. Thank you.😎

thearchivalone avatar Jul 03 '24 17:07 thearchivalone

Yes it's bit addictive =)

eprikazchikov avatar Jul 03 '24 18:07 eprikazchikov

Took a glance at the CMake files for all the unloaded plugins and they should link correctly. graph-editor is a dependency in all. I don’t have a Linux install right now but building a version with CMake and running natively from those builds could rule out if it’s the platform or the CMake build system. Getting a VM setup with an install to test on should be doable on my end. It doesn’t even need to run well, just be able to build and launch the editor.

thearchivalone avatar Jul 03 '24 18:07 thearchivalone

That stacktrace brought up a Camera pointer. There’s at least one unchecked one in Pipelinecontext that could be null. I took a brief look at the RenderSystem and RenderGLSystem code and didn’t see anything right off the bat.

I’ll check the fonts too. The crash happens right after they get loaded in and sometimes they and certain image formats will get mangled by git when cloning from my experiences. It’s a known bug that pops up every so often with the git port on the platform.

thearchivalone avatar Jul 03 '24 18:07 thearchivalone

When you setup the CMake system, did you assume a build inside tree or in an external folder? I think I found one of the problems.

I’m also confused about how the engine creates the virtual resource directory. I see the code looking for the resources and then assuming .embedded exists in memory. Definite black magic to me. That’s why I wasn’t sure if I should look for a hidden folder in the resources folder or not.

thearchivalone avatar Jul 03 '24 22:07 thearchivalone

I think you should check dependencies for this plugins using ldd or analog on BSD platform. They all uses grapheditor module

Just got home from work. Here's the BSD libraries, plugins and executables ldd logs. There's nothing that's linked wrong as far as I can see. ldd-logs.zip

ldd-exe.log

thearchivalone avatar Jul 04 '24 03:07 thearchivalone

My current assumption is that each of the failed plugins generated a warning of some type that I mindlessly didn't think much of. I'm building them individually and piping the warnings to a log. I'm also comparing my findings to the previous Linux build logs from your runners. I found some possible leads. Will post my findings here in a bit.

thearchivalone avatar Jul 04 '24 05:07 thearchivalone

This doesn't exist in the other logs and is mighty suspicious to me:

/home/brad/git/thunder/engine/includes/editor/converters/animconverter.h:0: Note: No relevant classes found. No output generated.

Here's the source code for that: https://github.com/thunder-engine/thunder/blob/master/engine/includes/editor/converters/animconverter.h

pipeline-warnings.log

And attached is the warning log for pipelinetools. It's not generating all of the headers even though they have no issues with the Linux build.

Seems to be not relevant or useful. It's just a standard moc warning stating that it doesn't need to process that header.

thearchivalone avatar Jul 04 '24 05:07 thearchivalone

When you setup the CMake system, did you assume a build inside tree or in an external folder? I think I found one of the problems.

I’m also confused about how the engine creates the virtual resource directory. I see the code looking for the resources and then assuming .embedded exists in memory. Definite black magic to me. That’s why I wasn’t sure if I should look for a hidden folder in the resources folder or not.

I think I forgot to prepare right install instructions fro CMake. Me personally using QBS because it's convenient to use it in Qt Creator IDE

eprikazchikov avatar Jul 04 '24 12:07 eprikazchikov

I think you should check dependencies for this plugins using ldd or analog on BSD platform. They all uses grapheditor module

Just got home from work. Here's the BSD libraries, plugins and executables ldd logs. There's nothing that's linked wrong as far as I can see. ldd-logs.zip

ldd-exe.log

Ok seems like all dependencies were resolved. Then it's missilery why it don't loading =/

eprikazchikov avatar Jul 04 '24 12:07 eprikazchikov