<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Vanille code crashes</title>
		<link>http://www.allegro.cc/forums/view/615612</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 11 Aug 2015 04:26:45 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I do this with 5.010:</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">  1</span>
<span class="number">  2</span><a href="http://www.allegro.cc/manual/al_lock_bitmap"><span class="a">al_lock_bitmap</span></a> <span class="k2">(</span>DTA<span class="k2">)</span><span class="k2">;</span>
<span class="number">  3</span><a href="http://www.allegro.cc/manual/al_set_target_bitmap"><span class="a">al_set_target_bitmap</span></a> <span class="k2">(</span>DTA,<a href="http://www.allegro.cc/manual/al_get_bitmap_format"><span class="a">al_get_bitmap_format</span></a><span class="k2">(</span>DTA<span class="k2">)</span>,READwRITE<span class="k2">)</span><span class="k2">;</span>
<span class="number">  4</span>a_draw_filled_rectangle <span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">300</span>,<span class="n">300</span>,<a href="http://www.allegro.cc/manual/al_map_rgb"><span class="a">al_map_rgb</span></a><span class="k2">(</span><span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">(</span><span class="k1">int</span><span class="k2">)</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span> 
<span class="number">  5</span>
<span class="number">  6</span><a href="http://www.allegro.cc/manual/al_unlock_bitmap"><span class="a">al_unlock_bitmap</span></a><span class="k2">(</span>DTA<span class="k2">)</span><span class="k2">;</span>
</div></div><p>

Code will crash reliably when drawing or clearing the bitmap. </p><p>Can someone help with this thing??
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Fri, 31 Jul 2015 15:11:15 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is there a special reason why you&#39;re locking the bitmap before drawing onto it?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Fri, 31 Jul 2015 16:08:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/615612/1015573#target">RPG Hacker</a> said:</div><div class="quote"><p> Is there a special reason why you&#39;re locking the bitmap before drawing onto it?</p></div></div><p>Actually yes. The manual tells me to do it :-))
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Fri, 31 Jul 2015 17:50:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Where exactly? Can you put the link here?<br />al_draw_filled_rectangle, as the name suggest, should be a drawing operation. And drawing operations normally don&#39;t require you to lock the target bitmap. I couldn&#39;t find anything in the manual that says to lock the bitmap before calling al_draw_filled_rectangle. Where did you read that?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Fri, 31 Jul 2015 18:37:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In fact <span class="ref"><sup>[<a href="#">1</a>]</sup></span> says:</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p>
Note: While a bitmap is locked, you can not use any drawing operations on it (with the sole exception of al_put_pixel and al_put_blended_pixel).
</p></div></div><p>
</p><div class="ref-block"><h2>References</h2><ol><li><a href="http://allegro5.org/docs/html/refman/graphics.html#al_lock_bitmap">http://allegro5.org/docs/html/refman/graphics.html#al_lock_bitmap</a></li></ol></div></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Fri, 31 Jul 2015 18:49:31 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I don&#39;t understand the confusion. You are very specifically doing drawing operations, which won&#39;t work on a locked bitmap.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Michael Moffitt)</author>
		<pubDate>Fri, 31 Jul 2015 23:40:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Actually I thought, bitmaps have to be locked to keep them from being changed otherwise. </p><p>At this current state it seems, it crashes without being locked too. Later I will have another look at it. </p><p><b>Update</b></p><p>It is as stated above. It changed position a little - after returning from this routine - but the effect stays the same. Using draw/clear crashes the program. <br />Could it be something with incompatible linked libraries???????
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Fri, 31 Jul 2015 23:54:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/615612/1015606#target">#00JMP00</a> said:</div><div class="quote"><p> Actually I thought, bitmaps have to be locked to keep them from being changed otherwise.</p></div></div><p>Nah, locking a bitmap has nothing to do with &quot;protecting&quot; it. I have to admit that the terminology can be a bit confusing. When you lock a bitmap, everything that happens is that you map its memory to the CPU. So depending on how exactly you lock the bitmap, you can either read its pixel data that was previously on the GPU, write new pixel data to the bitmap on the GPU or do both.</p><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p> At this current state it seems, it crashes without being locked too.</p></div></div><p>Can you post your whole code? Aside from the locking, there is nothing obviously wrong with the code above (except for your usage of al_set_target_bitmap, which normally takes only one argument, but I don&#39;t think that&#39;s the problem here).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Sat, 01 Aug 2015 02:48:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I post some of the relevant code. Posting the whole code wouldn&#39;t facilitate things. </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">  1</span>
<span class="number">  2</span><span class="p">#include &lt;allegro...&gt;</span>
<span class="number">  3</span><span class="p">#include ...</span>
<span class="number">  4</span><span class="p">#include...</span>
<span class="number">  5</span>
<span class="number">  6</span>
<span class="number">  7</span>
<span class="number">  8</span>
<span class="number">  9</span><span class="k1">void</span> <a href="http://www.allegro.cc/manual/clear_to_color"><span class="a">clear_to_color</span></a> <span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>DTA,<span class="k1">int</span> r,<span class="k1">int</span> g, <span class="k1">int</span> b<span class="k2">)</span><span class="k2">;</span>
<span class="number"> 10</span>
<span class="number"> 11</span><span class="k1">void</span> <a href="http://www.allegro.cc/manual/clear_to_color"><span class="a">clear_to_color</span></a> <span class="k2">(</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span> DTA,<span class="k1">int</span> r,<span class="k1">int</span> g, <span class="k1">int</span> b<span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 12</span>
<span class="number"> 13</span>
<span class="number"> 14</span><span class="c">// al_lock_bitmap (DTA,al_get_bitmap_format (DTA),ALLEGRO_LOCK_WRITEONLY);</span>
<span class="number"> 15</span>
<span class="number"> 16</span>
<span class="number"> 17</span><span class="c">// al_set_target_bitmap (DTA);</span>
<span class="number"> 18</span>al_msg<span class="k2">(</span><span class="s">"farbe int"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 19</span>
<span class="number"> 20</span><span class="c">// al_clear_to_color and al_draw_filled will both crash the program</span>
<span class="number"> 21</span><a href="http://www.allegro.cc/manual/al_clear_to_color"><span class="a">al_clear_to_color</span></a> <span class="k2">(</span><a href="http://www.allegro.cc/manual/al_map_rgb"><span class="a">al_map_rgb</span></a><span class="k2">(</span>r,g,b<span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 22</span>
<span class="number"> 23</span><span class="c">// al_draw_filled_rectangle (0,0,BM_W(DTA),BM_H(DTA),al_map_rgb(r,g,b));</span>
<span class="number"> 24</span>
<span class="number"> 25</span>al_msg<span class="k2">(</span><span class="s">"unlock"</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 26</span><span class="c">// al_unlock_bitmap(DTA);</span>
<span class="number"> 27</span><span class="k1">return</span><span class="k2">;</span>
<span class="number"> 28</span>
<span class="number"> 29</span><span class="k2">}</span>
<span class="number"> 30</span>
<span class="number"> 31</span><span class="k1">int</span> main <span class="k2">(</span>vip arguments <span class="k2">:</span><span class="k3">-</span><span class="k2">)</span><span class="k2">)</span> <span class="k2">{</span>
<span class="number"> 32</span>
<span class="number"> 33</span>
<span class="number"> 34</span><a href="http://www.allegro.cc/manual/ALLEGRO_BITMAP"><span class="a">ALLEGRO_BITMAP</span></a> <span class="k3">*</span>SBB <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">1024</span>,<span class="n">768</span><span class="k2">)</span><span class="k2">;</span> <span class="c">// Values are somewhat unimportant</span>
<span class="number"> 35</span>
<span class="number"> 36</span><a href="http://www.allegro.cc/manual/clear_to_color"><span class="a">clear_to_color</span></a> <span class="k2">(</span>SBB,<span class="n">0</span>,<span class="n">0</span>,<span class="n">0</span><span class="k2">)</span><span class="k2">;</span>
<span class="number"> 37</span>
<span class="number"> 38</span><span class="c">// Program will have crashed now</span>
<span class="number"> 39</span>
<span class="number"> 40</span>
<span class="number"> 41</span>
<span class="number"> 42</span><span class="k2">}</span>
</div></div><p>


To avoid the question in advance, the code crashes at runtime.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Sat, 01 Aug 2015 17:44:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Did you initialize Allegro and all relevant sub systems? (with <a href="https://www.allegro.cc/manual/5/al_init">al_init()</a> etc.)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Sat, 01 Aug 2015 20:06:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I guess yes. </p><p>I omitted this point and continued my way through the code. </p><p>Now I unearthed another issue:</p><p>Assertion failed: bitmap != destination &amp;&amp; bitmap != dest-&gt;parent, coming along <br />with a none existing path, ending &quot;allegro-git\src\bitmap_draw.c line33&quot;.</p><p>- It makes me wonder -
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Sat, 01 Aug 2015 20:38:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It says &#39;make sure the source bitmap is not a sub bitmap of the destination and make sure you&#39;re not drawing to yourself&#39;, basically. So you&#39;re doing one of those two things somehow.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 02 Aug 2015 01:41:16 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, I figured that out - thank you anyway. </p><p>The assertion failure is gone, but it still crashes. The assertion was <br />somewhat blind. </p><p>Maybe I get rid of the rest too.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Sun, 02 Aug 2015 02:31:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Use a debugger like GDB or MSVS built in debugger. Get the stack / backtrace from where it crashes, and then you can see why it is crashing by examining local variables usually.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Sun, 02 Aug 2015 03:21:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Using the debugger, once setup, was easier than thought. Unfortunately the come out wasn&#39;t worth the effort. </p><p>The error seems to change position sometimes. At the end I can tell, that location and/or size of an object (bitmap) shall be resolved. Last registered access is to ntdll.dll and allegro.../bitmap.c. There the value 0x0 is returned. I guess the value shouldn&#39;t be 0x0, thus crashing the program. </p><p>All object are in good order :-) and I do not understand this behaviour. </p><p>Update:</p><p>I found, when I use my function BM_h() - returning height of a bitmap, there will be a wrong value. Just now, program crashed with  -5901xxxxx. I guess negative values are not possible. </p><p>Hmmm.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Sun, 02 Aug 2015 20:38:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Are you checking all your pointers for NULL before doing anything with them? It sounds like you could accidentally be passing a NULL pointer into a function that doesn&#39;t support NULL pointers, thus the crash. I&#39;d check that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Mon, 03 Aug 2015 00:54:52 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">Quote:</div><div class="quote"><p> Are you checking your pointers...</p></div></div><p>I did and they where ok. Besides this, they are initialised and in use, though code would crash at other position. </p><p><b>Additional question</b></p><p>As I posted above, the assertion failed pointed to a none existing allegro ressource. Why is this? The path to the object requested d:/librariers/allegro... ist completely none existing and probably never existed before.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Mon, 03 Aug 2015 01:53:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/615612/1015676#target">#00JMP00</a> said:</div><div class="quote"><p> As I posted above, the assertion failed pointed to a none existing allegro ressource. Why is this? The path to the object requested d:/librariers/allegro... ist completely none existing and probably never existed before.</p></div></div><p>This probably refers to a path on the system the Allegro libs were build on. Or did you build the libs yourself?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Mon, 03 Aug 2015 13:12:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;ve got to tell your &#39;clear_to_color&#39; function which BMP it should be clearing!!</p><p><b>al_set_target_bitmap</b>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dizzy Egg)</author>
		<pubDate>Thu, 06 Aug 2015 15:20:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>There it was, but then has been outcommented :-))</p><p>It doesn&#39;t work anyway. </p><p>There still occurs an error when calling al_get_bitmap_height, in my version.</p><p>Error is still at ntdll.dll/allegro/bitmap.c. </p><p>Someone said, pointer is probably NULL, but the bitmap is set, since <br />the size can be read at other position. Looking at the debugger error, <br />it really seems to be this, but I can&#39;t change it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Fri, 07 Aug 2015 19:52:36 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I can&#39;t see <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_bitmap_height"><span class="a">al_get_bitmap_height</span></a></span> in your code!?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Dizzy Egg)</author>
		<pubDate>Fri, 07 Aug 2015 20:11:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Then you have anther look and reread my last posting.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Fri, 07 Aug 2015 23:00:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I did. There IS no al_get_bitmap_height in the code you posted above.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (RPG Hacker)</author>
		<pubDate>Mon, 10 Aug 2015 13:24:30 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Well, op was refering to al_set_target_bitmap...</p><p>therefore I was refering to this. </p><p>But at a closer look, even al_get_bitmap_height is there, <br />somewhat coated by a shorter version:</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">  1</span>
<span class="number">  2</span>
<span class="number">  3</span><span class="k1">int</span> BM_H <span class="k2">(</span>allegro_bitmap <span class="k3">*</span>DBM<span class="k2">)</span> <span class="k2">{</span>
<span class="number">  4</span>
<span class="number">  5</span>
<span class="number">  6</span><span class="k1">return</span> <a href="http://www.allegro.cc/manual/al_get_bitmap_height"><span class="a">al_get_bitmap_height</span></a> <span class="k2">(</span>DBM<span class="k2">)</span><span class="k2">;</span>
<span class="number">  7</span><span class="k2">}</span>
</div></div><p>

To eliminate the possibility of a problem here, I hand <br />wrote it in my version...</p><p>I actually would&#39;t want to put my code here.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (#00JMP00)</author>
		<pubDate>Mon, 10 Aug 2015 13:37:55 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_bitmap_height"><span class="a">al_get_bitmap_height</span></a></span> is returning crazy values it is because you are calling it on an uninitialized or dangling ALLEGRO_BITMAP*.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Tue, 11 Aug 2015 04:26:45 +0000</pubDate>
	</item>
</rss>
