Mail Archives: djgpp/1999/10/10/14:46:46
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 -