TheCherno / Hazel

Hazel Engine
Apache License 2.0
11.64k stars 1.5k forks source link

Crashes in RenderCommand during early initialization #574

Open 3x3y3z3t opened 2 years ago

3x3y3z3t commented 2 years ago

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:

  1. Go to RendererAPI::Create() function in RendererAPI.cpp
  2. 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)
    {
        // ...
    }
    }
  3. "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

Additional context

This bug happens in initialization phase, when all statics 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.