Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Allegro 5 fails to "assert mutex" when doing image = al_create_bitmap(x, x);

This thread is locked; no one can reply to it. rss feed Print
Allegro 5 fails to "assert mutex" when doing image = al_create_bitmap(x, x);
GudPiggeh
Member #16,492
July 2016

I'm trying to create a bitmap.

#SelectExpand
218void tile::imageLoad() { 219 std::cout << "Loading " << fileName << std::endl; 220 //some code 221 image = al_create_bitmap(NUMBER, NUMBER); 222 //some code 223 std::cout << "Loaded " << fileName << std::endl; 224}

Somehow, as it does image = al_create_bitmap(1, 1);, it gives Assertion failed: mutex, file C:\dev\allegro_winpkg\universal\allegro\src\threads.c, line 310
and aborts. ???
This used to work before, but somehow changing something out both out of this function and out of tile has caused this.

jmasterx
Member #11,410
October 2009

We're going to need more context than that! You're even assigning to a variable that is outside the scope of the function (member variable (Or global ???)).
Of course this code in itself is 100% fine, but a lot more can go wrong before the call to al_create_bitmap.
How do you init allegro? Is Allegro initialized with hardware acceleration support?
Does creating a 64x64 bitmap work?
Copy pasting the code somewhere else to see if that works?
Are you doing crazy multithreaded rendering / was Allegro initialized on another thread?
Are you running out of memory?
Could you have caused memory or heap corruption elsewhere?
If you're really up for an adventure, crack open the Allegro source code and find out how that mutex can be NULL.

Edgar Reynaldo
Member #8,592
May 2007
avatar

My guess is you're using a global Tile object, and it's trying to create the bitmap before allegro has been initialized.

But it could be a lot of things. I can't tell you where in the source code that is, because GIT has diverged from 5.2.2 and the sources don't match up anymore.

jmasterx
Member #11,410
October 2009

Edgar Reynaldo
Member #8,592
May 2007
avatar

Go to: