Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7661053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:32:51+00:00 2026-05-31T13:32:51+00:00

I am trying to compile a program that compiles perfectly fine on my desktop

  • 0

I am trying to compile a program that compiles perfectly fine on my desktop but on my laptop, it compiles but gives me this error whenever it is run:

Windows has triggered a breakpoint in RR.exe.

This may be due to a corruption of the heap, which indicates a bug in
RR.exe or any of the DLLs it has loaded.

This may also be due to the user pressing F12 while RR.exe has focus.

The output window may have more diagnostic information.

I’ve commented out lines till I found the line that makes the error which is:

if(glfwOpenWindow(width_, height_, 0, 0, 0, 0, 32, 0, GLFW_WINDOW) != GL_TRUE) {
    throw std::runtime_error("Unable to open GLFW window");
}

The weird thing is if I replace width_ and height_ with constants, e.g. 800 and 600 respectively, it stops the heap corruption. Also if I just use the default values set by the constructor instead of passing values it doesn’t crash.

Here’s the complete code. The above lines are in the Window constructor.

window.h

#pragma once

#include <iostream>
#include <GL\glew.h>
#include <GL\glfw.h>

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#pragma comment(lib, "glew32.lib")
#pragma comment(lib, "GLFW.lib")

class Window {
public:
    Window(unsigned width = 800, unsigned height = 600);
    ~Window();

    void clear();
    inline void display() { glfwSwapBuffers(); }
    inline bool exit() { return !glfwGetWindowParam(GLFW_OPENED); }

private:
    unsigned width_, height_;
};

window.cpp

#include "window.h"

Window::Window(unsigned width, unsigned height) : width_(width), height_(height) {
    if(glfwInit() != GL_TRUE) {
        throw std::runtime_error("Unable to initialize GLFW");
    }

    if(glfwOpenWindow(width_, height_, 0, 0, 0, 0, 32, 0, GLFW_WINDOW) != GL_TRUE) { //crash
    //if(glfwOpenWindow(800, 600, 0, 0, 0, 0, 32, 0, GLFW_WINDOW) != GL_TRUE) { //no crash
        throw std::runtime_error("Unable to open GLFW window");
    }

    GLenum result = glewInit();
    if(result != GLEW_OK) {
        std::stringstream ss;
        ss << "Unable to initialize glew: " << glewGetErrorString(result);
        throw std::runtime_error(ss.str());
    }
}

Window::~Window() {
    glfwTerminate();
}

void Window::clear() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
}

main.cpp

#include "window.h"

int main() {
    Window wind(1024, 800); //crash
    Window wind(800, 600); //crash
    Window wind(); //works

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T13:32:52+00:00Added an answer on May 31, 2026 at 1:32 pm

    The problem seems lead with glfw:

    I assume, you are trying to use dynamically linked GLFW. Note in glfw header:

    #if defined(_WIN32) && defined(GLFW_BUILD_DLL)
    
    /* We are building a Win32 DLL */
     #define GLFWAPI      __declspec(dllexport)
     #define GLFWAPIENTRY __stdcall
     #define GLFWCALL     __stdcall
    #elif defined(_WIN32) && defined(GLFW_DLL)
    
     /* We are calling a Win32 DLL */
     #if defined(__LCC__)
      #define GLFWAPI      extern
     #else
      #define GLFWAPI      __declspec(dllimport)
     #endif
     #define GLFWAPIENTRY __stdcall
     #define GLFWCALL     __stdcall
    
    #else
    
     /* We are either building/calling a static lib or we are non-win32 */
     #define GLFWAPIENTRY
     #define GLFWAPI
     #define GLFWCALL
    
    #endif
    

    GLFW_BUILD_DLL apparently was set while building dll, and it defined API functions with __stdcall calling conversion.

    But when using library you haven’t defined GLFW_DLL, so your code assumed __cdecl calling conversion. The difference between _cdecl and __stdcall in general is that caller function should clean the stack in first and callee in last case. So you cleaned the stack twice, that’s why you got stack corruption.

    After I defined GLFW_DLL before including glfw in your program, it started working correctly. Also note, that I used mingw and had to link against glfwdll.a instead of glfw.a after defining GLFW_DLL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when I'm trying to compile my c program it gives me this error warning:
I am trying to run an ant build script that compiles GWT. This script
I'm getting a totally bizzare error trying to compile a C program using GCC.
I am trying to compile a one-off script, an autogenerated C# program. This program
My program has been working perfectly so far, but it turns out that I've
I'm trying to compile a java program that is using JavaDB/Derby. On the command
I am trying to compile a program that is created from Visual Studio 8,
I am trying to compile a program that uses the function clock_gettime . The
I'm trying to write a program that compiles in Borland C++ and Visual C++.
I'm hitting a compile error in VS2010 with code that compiles cleanly in VS2008.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.