I'm writing an game engine, where the engine is written in a project and exports a .dll file. In another project, in the same solution as the engine, there is a sandbox project which uses the engine. However, there is a bug.
I run the sandbox project in debug mode with the engine dll. When I spam my mouse and keyboard for a few seconds, and close the program via the exit button, the program crashes with an error:
Exception thrown at 0x00000043 in phantom-sandbox.exe: 0xC0000005: Access violation executing location 0x00000043.
If there is a handler for this exception, the program may be safely continued.
I found the source of the bug. Since I'm currently writing the engine for OpenGL, I have to initialize GLEW, and I need to create a HGLRC
. If I don't initialize this HGLRC
, everything works.
This is not the ideal solution, since I need to use OpenGL for my engine. I went forth without exporting the .dll from the engine, making the engine an application, instead. I made a main.cpp
, and wrote it to use the engine, enabling OpenGL rendering. I tried to recreate the bug, but everything works!
I thought it might OpenGL, but then now I'm thinking it might be my engine. How do I fix this?
Here is my code, where it errors:
int const main_result = invoke_main()
__telemetry_main_return_trigger(nullptr);
if(!__scrt_is_managed_app())
exit(main_result)l
if(!has_actor) // < this is the line being sent to the call stack
_cexit();
__scrt_unititialize_crt(true, false);
return main_result;
}
__except (_seh_filter_exe(GetExceptionCode(), GetExceptionInformation()))
{
int const main_result = GetExceptionCode();
if(!__scrt_is_managed_app())
_exit(main_result);
Here is the call stack: