Skip to main content
grammar and punctuation; removed blacklisted engine tag; converted error and code to text
Source Link
Gnemlock
  • 5.3k
  • 5
  • 30
  • 60

Access Violation on Application Exit How do I fix this access violation when I exit my custom OpenGL game engine?

Currently I'm writing an Engine. How I have it right now is thatgame engine, where the engine is written in a project and exports a dll. Ondll file. In another project, in the same solution as the engine, there is a sandbox project which uses the engine.

Like this However, I write code the engine and sandbox. But there is a bug. The way to produce this bug is that, 

I run the sandbox project in debug mode with the engine dll. When iI spam my mouse and keyboard for a few seconds, and close the program via the exit button. The, the program crashes.

In debug mode. The crash is here with an error: opengl_glew_init_exception opengl_glew_init_breakpoint

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 out what produces the source of the bug. Since imI'm currently writing the engine for opengl.OpenGL, I have to use initialize glewGLEW, and iI need to create a HGLRC. So i do that. But this is the issueHGLRC. If iI don't initialize it and try to recreate the bug. Everything is all goochithis HGLRC, everything works.

But this can never beThis is not the ideal solution, since I need to use openglOpenGL for my engine. So iI went forth and decided to not exportwithout exporting the dll.dll from the engine. But instead make, making the engine an application, instead. So iI made a main.cppmain.cpp, and wrote stuffit to use the engine. Enabled opengl, enabling OpenGL rendering. TriedI tried to recreate the bug. But, but everything works!

So at first I thought it might be me being stupid with opengl. ButOpenGL, but then i found out it works when i make my engine an application. So now i'mI'm thinking it might be my engine. How do I fix this?

 

Has anyone had this issue before ? Or does anyone know why thisHere is happening ? Any solutions ?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);

Thank you in advance ~Here is the call stack:

enter image description here

Access Violation on Application Exit

Currently I'm writing an Engine. How I have it right now is that, the engine is written in a project and exports a dll. On another project in the same solution as the engine, there is a sandbox project which uses the engine.

Like this, I write code the engine and sandbox. But there is a bug. The way to produce this bug is that, 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.

In debug mode. The crash is here: opengl_glew_init_exception opengl_glew_init_breakpoint

I found out what produces the bug. Since im currently writing the engine for opengl. I have to use initialize glew and i need to create a HGLRC. So i do that. But this is the issue. If i don't initialize it and try to recreate the bug. Everything is all goochi.

But this can never be the solution since I need to use opengl for my engine. So i went forth and decided to not export the dll from the engine. But instead make the engine an application. So i made a main.cpp and wrote stuff to use the engine. Enabled opengl rendering. Tried to recreate the bug. But everything works!

So at first I thought it might be me being stupid with opengl. But then i found out it works when i make my engine an application. So now i'm thinking it might be my engine.

Has anyone had this issue before ? Or does anyone know why this is happening ? Any solutions ?

Thank you in advance ~

How do I fix this access violation when I exit my custom OpenGL game engine?

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:

enter image description here

Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link
JekasG
  • 21
  • 1
  • 3

Access Violation on Application Exit

Currently I'm writing an Engine. How I have it right now is that, the engine is written in a project and exports a dll. On another project in the same solution as the engine, there is a sandbox project which uses the engine.

Like this, I write code the engine and sandbox. But there is a bug. The way to produce this bug is that, 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.

In debug mode. The crash is here: opengl_glew_init_exception opengl_glew_init_breakpoint

I found out what produces the bug. Since im currently writing the engine for opengl. I have to use initialize glew and i need to create a HGLRC. So i do that. But this is the issue. If i don't initialize it and try to recreate the bug. Everything is all goochi.

But this can never be the solution since I need to use opengl for my engine. So i went forth and decided to not export the dll from the engine. But instead make the engine an application. So i made a main.cpp and wrote stuff to use the engine. Enabled opengl rendering. Tried to recreate the bug. But everything works!

So at first I thought it might be me being stupid with opengl. But then i found out it works when i make my engine an application. So now i'm thinking it might be my engine.

Has anyone had this issue before ? Or does anyone know why this is happening ? Any solutions ?

Thank you in advance ~