Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 6, 2026

Windows throws a first-chance exception 0x8007007A (ERROR_INSUFFICIENT_BUFFER) inside _glfwInitWGL at SetPixelFormat during GLFW window creation. This is a known benign WGL initialization behavior that can cause issues when running under a debugger or with certain exception handlers.

Changes

  • Added Windows SEH wrapper createWindowWithSEH to catch and handle the specific exception
  • Exception filter only handles 0x8007007A, other exceptions pass through via EXCEPTION_CONTINUE_SEARCH
  • Logs exception code for diagnostics when caught
  • Windows-only (#ifdef _WIN32), no impact on Linux/Mac builds
#ifdef _WIN32
    int wglExceptionFilter(unsigned int code, unsigned int* capturedCode)
    {
        *capturedCode = code;
        if (code == EXCEPTION_WGL_INSUFFICIENT_BUFFER) {
            return EXCEPTION_EXECUTE_HANDLER;
        }
        return EXCEPTION_CONTINUE_SEARCH;
    }

    GLFWwindow* createWindowWithSEH(int width, int height, const char* title, GLFWmonitor* monitor, GLFWwindow* share)
    {
        GLFWwindow* window = nullptr;
        unsigned int exceptionCode = 0;
        __try {
            window = glfwCreateWindow(width, height, title, monitor, share);
        } __except (wglExceptionFilter(GetExceptionCode(), &exceptionCode)) {
            log(Priority::Important, "caught Windows exception 0x" + ... + " during glfwCreateWindow");
            window = nullptr;
        }
        return window;
    }
#endif
Original prompt

During startup of alien there is an exception in glfwCreateWindow (inside GLFWbool _glfwInitWGL(void) at SetPixelFormat, "Exception thrown at 0x00007FF9FC37782A (KernelBase.dll) in alien.exe: WinRT originate error - 0x8007007A : 'Der an einen Systemaufruf übergebene Datenbereich ist zu klein.'.").
Find the reason and fix it.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Add SEH wrapper to catch benign 0x8007007A (ERROR_INSUFFICIENT_BUFFER)
exception that can occur during WGL initialization at SetPixelFormat.

Co-authored-by: chrxh <[email protected]>
Copilot AI changed the title [WIP] Fix exception in glfwCreateWindow during startup Fix Windows WinRT exception during glfwCreateWindow startup Jan 6, 2026
Copilot AI requested a review from chrxh January 6, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants