I'm using Allegro 5.2.6 for my simple c++ project. Line with al_create_display
function throws Allegro_2.exe has triggered a breakpoint.
, after pressing "Continue" the same line throws
Unhandled exception at 0x00007FFB1394DEC9 (ntdll.dll) in Allegro_2.exe:
0xC0000374: A heap has been corrupted (parameters: 0x00007FFB139B67F0).
If start application outside the VS, it just crashes without any messages. It happens with ~20% chance and only with x64 platform regardless of configuration is release or debug.
Here is my code before the problematic line:
#include <Windows.h>
#include <WinUser.h>
#include <winnt.h>
#include <string>
#include <iostream>
#include <stdint.h>
#include <allegro5/allegro5.h>
#include <allegro5/allegro_ttf.h>
#include "init_exception.h" //My custom exception.
#include "runtime_exception.h" //My custom exception.
#include "fps_meter.h" //My custom class.
#define int64 uint64_t
#define int16 uint16_t
const int16 fps = 60;
const int width = 1000, height = 640;
bool running = true;
ALLEGRO_DISPLAY* display = nullptr;
ALLEGRO_TIMER* timer = nullptr;
ALLEGRO_EVENT_QUEUE* event_queue = nullptr;
fps_meter* meter;
void start_game() {
//Initialize allegro.
if (!al_init()) {
throw init_exception("Failed to initialize allegro!");
}
//Inititalize font addon.
if (!al_init_ttf_addon()) {
throw init_exception("Failed to initialize ttf addon!");
}
//Create the display.
display = al_create_display(width, height);// <=== EXCEPTION HERE
if (!display) {
//Failed to create display.
throw init_exception("Failed to create display!", (int64)width << 32 | height);
}
...
}
int main() {
try {
start_game();
}
catch (init_exception e) {
MessageBoxA(NULL, e.what(), "Initialization error!", MB_ICONERROR | MB_OK);
delete[] e.what();
}
catch (runtime_exception e) {
MessageBoxA(NULL, e.what(), "Runtime error!", MB_ICONERROR | MB_OK);
delete[] e.what();
}
catch (std::exception e) {
MessageBoxA(NULL, e.what(), "Unknown error!", MB_ICONERROR | MB_OK);
}
catch (...) {
MessageBoxA(NULL, "An unknown error occured!", "Unknown error!", MB_ICONERROR | MB_OK);
}
return 0;
}
The try/catch
construction doesn't triggers.
I'm tried change some project properties, but it doesn`t help.
I hope i'm not first with this problem and you can help me.
User contributions licensed under CC BY-SA 3.0