bsf icon indicating copy to clipboard operation
bsf copied to clipboard

Crash/Stackoverflow when using gDebug() before initializing bsf

Open ataulien opened this issue 6 years ago • 1 comments

I tried to put some log output before I actually open the window and noticed some very strange behavior: The bs::LogEntry-class tries to access bs::Time, which then goes on to report a crash because it's not initialized.

The crash-reporter then goes and tries to write a log-entry, which of course fails and causes another crash, and so on. For some reason, I don't get a stack overflow error, the program just hangs and does nothing.

I understand that maybe one isn't supposed to use gDebug() before the application is initialized (which also opens the window), but I feel like this is a case which could be checked before sending the program into crashing over and over again.

Here is some of the initial call stack:

... 
#1053 0x00007ffff770d379 in bs::CrashHandler::reportCrash (this=0x0, type=..., description=..., function=..., file=..., line=<optimized out>) at /home/andre/code/bsf/Source/Foundation/bsfUtility/Private/Unix/BsUnixCrashHandler.cpp:177
#1054 0x00007ffff7694c39 in bs::Module<bs::Time>::instance () at /home/andre/code/bsf/Source/Foundation/bsfUtility/Utility/BsModule.h:26
#1055 0x00007ffff76948e5 in bs::gTime () at /home/andre/code/bsf/Source/Foundation/bsfUtility/Utility/BsTime.cpp:142
#1056 0x00007ffff76b1da7 in bs::LogEntry::LogEntry (channel=2, msg="\220\330\377\377\377\177\000\000\000\000\000", this=0x7fffffffd8a0) at /usr/include/c++/8/bits/char_traits.h:285
#1057 bs::Log::logMsg (this=0x7ffff7f8a108 <bs::gDebug()::debug+40>, message="A fatal error occurred and the program has to terminate!\n  - Error: InternalErrorException\n  - Description: Trying to access a module but it hasn't been started up yet.\n  - In function: static T& bs::"..., channel=channel@entry=2) at /home/andre/code/bsf/Source/Foundation/bsfUtility/Debug/BsLog.cpp:17
#1058 0x00007ffff76b5972 in bs::Debug::logError (this=<optimized out>, msg="A fatal error occurred and the program has to terminate!\n  - Error: InternalErrorException\n  - Description: Trying to access a module but it hasn't been started up yet.\n  - In function: static T& bs::"...) at /home/andre/code/bsf/Source/Foundation/bsfUtility/Debug/BsDebug.cpp:49
#1059 0x00007ffff76f1619 in bs::CrashHandler::logErrorAndStackTrace (this=this@entry=0x0, errorMsg="  - Error: InternalErrorException\n  - Description: Trying to access a module but it hasn't been started up yet.\n  - In function: static T& bs::Module<T>::instance() [with T = bs::Time]\n  - In file: /h"..., stackTrace="0) /usr/local/lib/libbsf.so.1: bs::CrashHandler::getStackTrace[abi:cxx11]()+0x1d2 [0x7ffff770db22]\n1) /usr/local/lib/libbsf.so.1: bs::CrashHandler::logErrorAndStackTrace(std::__cxx11::basic_string<cha"...) at /usr/include/c++/8/bits/basic_string.h:1918
#1060 0x00007ffff76f1b32 in bs::CrashHandler::logErrorAndStackTrace (this=this@entry=0x0, type=..., description=..., function=..., file="/home/andre/code/bsf/Source/Foundation/bsfUtility/Utility/BsModule.h", line=31) at /usr/include/c++/8/bits/basic_string.h:1918
#1061 0x00007ffff770d379 in bs::CrashHandler::reportCrash (this=0x0, type=..., description=..., function=..., file=..., line=<optimized out>) at /home/andre/code/bsf/Source/Foundation/bsfUtility/Private/Unix/BsUnixCrashHandler.cpp:177
#1062 0x00007ffff7694c39 in bs::Module<bs::Time>::instance () at /home/andre/code/bsf/Source/Foundation/bsfUtility/Utility/BsModule.h:26
#1063 0x00007ffff76948e5 in bs::gTime () at /home/andre/code/bsf/Source/Foundation/bsfUtility/Utility/BsTime.cpp:142
#1064 0x00007ffff76b1da7 in bs::LogEntry::LogEntry (channel=0, msg="`\336\377\377\377\177\000\000\000\000\000", this=0x7fffffffde70) at /usr/include/c++/8/bits/char_traits.h:285
#1065 bs::Log::logMsg (this=0x7ffff7f8a108 <bs::gDebug()::debug+40>, message="[Main] Starting REGoth", channel=channel@entry=0) at /home/andre/code/bsf/Source/Foundation/bsfUtility/Debug/BsLog.cpp:17
#1066 0x00007ffff76b591f in bs::Debug::logDebug (this=<optimized out>, msg="[Main] Starting REGoth") at /home/andre/code/bsf/Source/Foundation/bsfUtility/Debug/BsDebug.cpp:37
#1067 0x0000555555561034 in main (argc=<optimized out>, argv=<optimized out>) at /usr/include/c++/8/bits/char_traits.h:285

ataulien avatar Mar 19 '19 10:03 ataulien

Thanks, I experienced this one before. It's not high priority but I agree it should eventually be resolved.

BearishSun avatar Mar 19 '19 16:03 BearishSun