delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/10/14:46:46

Date: Sun, 10 Oct 1999 12:30:30 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Nicolas Blais <nicblais AT hotmail DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Allegro matrix problem now is a djgpp prob
In-Reply-To: <7tj6mk$e5f$1@nnrp1.deja.com>
Message-ID: <Pine.SUN.3.91.991010123004.19618W-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Thu, 7 Oct 1999, Nicolas Blais wrote:

> Well, now allegro doesn't crash anymore, it's DJGPP.

No, it's still a bug in your program.  Keep looking.

> Here's the error symified:
> Shutting down Allegro
> Exiting due to signal SIGSEGV
> Page fault at eip=00057ecd, error=0007
> eax=000000b7 ebx=00057fe8 ecx=00000010 edx=7f678b89 esi=00057fe8
> edi=002e9f58
> ebp=00000fbc esp=00000fbc program=C:\DJGPP\PROJECTS\ILLIS\MAIN.EXE
> cs: sel=00af  base=82e7c000  limit=fff4cfff
> ds: sel=00b7  base=82e7c000  limit=fff4cfff
> es: sel=00b7  base=82e7c000  limit=fff4cfff
> fs: sel=00c7  base=00000000  limit=0010ffff
> gs: sel=00c7  base=00000000  limit=0010ffff
> ss: sel=029b  invalid
  ^^^^^^^^^^^^^^^^^^^^^
See?  Your stack segment is invalid.  Somehow, you have succeeded to
trash it.  You need to establish why.

> I have no idead what it means but here's my modified code that makes it
> crash:
> where RGB is actually defined as makecol15, res_x is 640 and res_y is
> 480 and ushort is unsigned short int.

Is that a full code of your program?  If so, where's the main
function?

Please post the source of a shortest full program that crashes like
above, so that it could be compiled and run under a debugger.

One thing that isn't clear from your snippet is how were res_x and
res_y declared.  If they are declared ushort, then res_x*res_y
overflows, and your loop goes awry.

> ushort pix_x;
> ushort pix_y;
> ushort color_red;
> unsigned int matrix[res_x][res_y] = {{0}};
> 
> for (unsigned int i = 0; i < (res_x * res_y); i++)
>      {
>      if (keypressed())
>         break;
>      pix_x = (rand() % res_x);
>      pix_y = (rand() % res_y);
>      if (matrix[pix_x][pix_y] == 1)
>         continue;
>      else
>           matrix[pix_x][pix_y] = 1;
>      color_red = (rand() % 255) + 1;
>      putpixel(screen, pix_x, pix_y, RGB(color_red, 0, 0));
>      }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019