<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro 5 fails to &quot;assert mutex&quot; when doing image = al_create_bitmap(x, x);</title>
		<link>http://www.allegro.cc/forums/view/616952</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 25 Jun 2017 21:36:58 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;m trying to create a bitmap.</p><div class="source-code"><div class="toolbar"><span class="button numbers"><b>#</b></span><span class="button select">Select</span><span class="button expand">Expand</span></div><div class="inner"><span class="number"> 218</span><span class="k1">void</span> tile::imageLoad<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 219</span>  std::cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"Loading "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> fileName <span class="k3">&lt;</span><span class="k3">&lt;</span> std::endl<span class="k2">;</span>  
<span class="number"> 220</span>        <span class="c">//some code</span>
<span class="number"> 221</span>    image <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_bitmap"><span class="a">al_create_bitmap</span></a><span class="k2">(</span>NUMBER, NUMBER<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 222</span>        <span class="c">//some code</span>
<span class="number"> 223</span>  std::cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"Loaded "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> fileName <span class="k3">&lt;</span><span class="k3">&lt;</span> std::endl<span class="k2">;</span>
<span class="number"> 224</span><span class="k2">}</span>
</div></div><p>
Somehow, as it does <span class="source-code"> image <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_create_bitmap"><span class="a">al_create_bitmap</span></a><span class="k2">(</span><span class="n">1</span>, <span class="n">1</span><span class="k2">)</span><span class="k2">;</span></span>, it gives <span class="source-code">Assertion failed: mutex, file C:\dev\allegro_winpkg\universal\allegro\src\threads.c, <a href="http://www.allegro.cc/manual/line"><span class="a">line</span></a> <span class="n">310</span></span><br />and aborts. <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" /><br />This used to work before, but somehow changing something out both out of this function and out of <span class="source-code">tile</span> has caused this.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GudPiggeh)</author>
		<pubDate>Sun, 25 Jun 2017 09:37:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>We&#39;re going to need more context than that! You&#39;re even assigning to a variable that is outside the scope of the function (member variable (Or global <img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />)).<br />Of course this code in itself is 100% fine, but a lot more can go wrong before the call to al_create_bitmap.<br />How do you init allegro? Is Allegro initialized with hardware acceleration support?<br />Does creating a 64x64 bitmap work?<br />Copy pasting the code somewhere else to see if that works?<br />Are you doing crazy multithreaded rendering / was Allegro initialized on another thread?<br />Are you running out of memory?<br />Could you have caused memory or heap corruption elsewhere?<br />If you&#39;re really up for an adventure, crack open the Allegro source code and find out how that mutex can be NULL.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sun, 25 Jun 2017 16:46:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My guess is you&#39;re using a global Tile object, and it&#39;s trying to create the bitmap before allegro has been initialized.</p><p>But it could be a lot of things. I can&#39;t tell you where in the source code that is, because GIT has diverged from 5.2.2 and the sources don&#39;t match up anymore.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 25 Jun 2017 20:31:23 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>@Edgar<br /><a href="https://github.com/liballeg/allegro5/blob/5.2.2/src/threads.c#L310">https://github.com/liballeg/allegro5/blob/5.2.2/src/threads.c#L310</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (jmasterx)</author>
		<pubDate>Sun, 25 Jun 2017 21:06:37 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The only reason a mutex wouldn&#39;t be valid is because you haven&#39;t called al_init first.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 25 Jun 2017 21:36:58 +0000</pubDate>
	</item>
</rss>
