Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » Odd memory accessing error since 5.0.7

This thread is locked; no one can reply to it. rss feed Print
Odd memory accessing error since 5.0.7
lawless
Member #14,694
November 2012

I am very noobish into C++, Allegro, Compilers and whatsoever and i definately need a lot of help :D

Well i wrote that piece of code some weeks ago under Allegro 5.0.6, using Codeblocks 10.5 and their integrated MingW/Gcc compiler thingie. Today finally i could manage to spend some time learning and programming again. The odd thing is I must have broken either my IDE or my compiler when I paused, because lots and lots of linking errors and other bugs I don't know about.

So I invested some time and got Codeblocks, the newest version of MingW and of course Allegro running, finally. Took me quite a while to figure it all out. When I started my little programm it just showed up there for a second, then crashed, saying:

Process returned -1073741819 (0xC0000005)

After some time looking for that stuff on google, i knew it was some memory accessing/allocating problem. The last couple hours I spent testing my code with al_rest() and some other nice ideas I had, for showing me when exactly this problem occurs.

I started another testproject, in which I copied all the necessary stuff, testing again and again, copying and finally it crashed. Some more time spend testing, I now know that the problem occurs at

al_flip_display and
al_clear_to_color

#SelectExpand
1#include<allegro5/allegro.h> 2#include<allegro5/allegro_native_dialog.h> 3 4 5const int ScreenWidth = 200; 6const int ScreenHeight = 200; 7const int WindowPositionX = 500; 8const int WindowPositionY = 200; 9 10bool done = false; 11 12int main() 13{ 14 15 al_init(); 16 17 al_set_new_display_flags(ALLEGRO_WINDOWED); // Set the Game in Windowmode (or Fullscreen or resizeable) 18 ALLEGRO_DISPLAY *display = NULL; // Create the Display via Variable 19 display = al_create_display(ScreenWidth,ScreenHeight); // Set the Display to specific size 20 al_set_window_position(display, WindowPositionX,WindowPositionY); // Set the Position of the Game-Window 21 al_set_window_title(display, "Allegro TEST"); // Set the Window Title 22 if(!display) 23 { 24 al_show_native_message_box(NULL, NULL, NULL, "I have failed to initialize the display", NULL, NULL); 25 return -1; 26 } 27 28 if(!al_install_keyboard()) // Init Keyboard 29 { 30 al_show_native_message_box(NULL, NULL, NULL, "I have failed to initialize your keyboard", NULL, NULL); 31 return -1; 32 } 33 34 if(!al_install_mouse()) // Init Mouse 35 { 36 al_show_native_message_box(NULL, NULL, NULL, "I have failed to initialize your mouse", NULL, NULL); 37 return -1; 38 } 39 al_hide_mouse_cursor(display); // Hides the Mousecursor 40 41 42 ALLEGRO_EVENT_QUEUE *event_queue = NULL; // Create the Input-Queue 43 event_queue = al_create_event_queue(); // Set the Event Queue to catch something 44 al_register_event_source(event_queue, al_get_keyboard_event_source()); // Keyboard to Event Queue 45 al_register_event_source(event_queue, al_get_mouse_event_source()); // Mouse to Event Queue 46 47 48 49 50 // Initializing the Crosshair 51 int MouseX = ScreenWidth/2; 52 int MouseY = ScreenHeight/2; 53 54 55 while(!done) 56 { 57 58 ALLEGRO_EVENT ev; // Create the Event Variable 59 al_wait_for_event(event_queue, &ev); // Wait for input 60 61 if(ev.type == ALLEGRO_EVENT_MOUSE_AXES) // Mouse Movement 62 { 63 MouseX = ev.mouse.x; 64 MouseY = ev.mouse.y; 65 } 66 67 if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) // Press the Window Close Button 68 { 69 done = true; 70 } 71 72 73 al_flip_display(); // Buffer to Screen 74 al_clear_to_color(al_map_rgb(0,0,0)); // Reset the Buffer to Black 75 76 77 } 78 79 return 0; 80}

The funny thing is:
If i out-comment the al_clear_to_color statement, the window will show up and stay without errors.

What is happening there? :'(

Update
I think i "fixed" the problem. Installing Allegro on my "old" MingW inside the Codeblocks folder and adding the libstdc++6.dll (what caused other problems in the first place) solved my issue. I just don't know why my new MingW doesn't want to do that stuff the right way.

I finally found some version data too:
New:
gcc-4.7.2-1-mingw32
mingwrt-3.20-2-mingw32

Old:
mingwrt-3.16-mingw32
GCC 4.4.1

So it works with the old one for now ;D

Go to: