Hazel
Hazel copied to clipboard
Crashes in RenderCommand during early initialization
Describe the bug
RendererAPI creation in RenderCommand.cpp
will crash if we try to log something in RendererAPI::Create()
function.
To Reproduce
Steps to reproduce the behavior:
- Go to
RendererAPI::Create()
function in RendererAPI.cpp - Add some log call in this function. For example,
Scope<RendererAPI> RendererAPI::Create()
{
HZ_CORE_INFO("Crash on this line"); // <- add this line;
switch (s_API)
{
// ...
}
}
- "Let's hit F5 and see what happens" (I mean, the program will crash on that log call).
Expected behavior
The program should not crash.
Development environment
- OS: Windows 10 Pro
- Visual Studio: VS2019 (also tested on VS2017)
Additional context
This bug happens in initialization phase, when all static
s is initialized. During this phase, Hazel::Log
is not initialized yet (execution has not yet reach the main function). Despite that, a call to Hazel's other system (RendererAPI) was made.
This bug was invisible due to there is no log call made in that function. At one point in the future when we need to log something in that function, the bug will reveal itself.