[fpc-pascal]GPF

Jonas Maebe jonas at zeus.rug.ac.be
Tue Sep 17 15:10:17 CEST 2002


On dinsdag, september 17, 2002, at 02:25 , A.J. Venter wrote:

> I have now :-)
> (That option is not in the manpage nor have I ever found it in the 
> docs -
> I wish I knew about it before)

It should be in the docs (well, -g is in there, -gh and -gl should be 
mentioned as well). It's definitely in the help that you get when 
running ppc386 without any parameters.

> Here is the output:
> General protection fault.
> No heap dump by heaptrc unit
> Exitcode = 216
> Runtime error 216 at 0x0804B8B4
>   0x0804B8B4  CHARACTERS__SETIMAGE,  line 212 of levelobj.pas
>   0x0804B913  CHARACTERS__SETSTATUS,  line 221 of levelobj.pas
>   0x0804BBF0  CHARACTERS__DRAW,  line 283 of levelobj.pas
>   0x0804B68C  LEVELS__DRAW,  line 148 of levelobj.pas
>   0x0804C372  LEVELS__INIT,  line 447 of levelobj.pas
>   0x0805BD82  MAINLOOP,  line 157 of minerunner.pas
>   0x0805BFFE  main,  line 224 of minerunner.pas
>   0x08048C17
>
> So how exactly does one read it ?

It's a backtrace of the callstack. The place where your program crashed 
is address 0x0804B8B4, which is an instruction generated for line 212 of 
levelobj.pas, which is part of the method characters.setimage(). This 
method was called from line 221 of levelobj.pas within 
characters.setstatus etc.

> It would appear from this that characters.setImage crashed -

Indeed.

> could it be that
> SDL crashes if the same bitmap file is loaded too often ? Or perhaps 
> there
> is something else that goes wrong when I do this.

I honestly don't know. To find this out, you should run the program in 
gdb, then you can view the values of the variables and fields when the 
program crashes.

> What I will do next is to recode it so that setStatus merely changes a
> string
> with the path to the correct image, and then use SDL_BlitSurface with
> SDL_LoadBMP as a parameter (e.g. only load on demand) but this could
> severly slow down the program so it is not really a final solution, and
> even
> when the enemy bitmaps are
> finished, surely I must be able to use the same file for all of them ?

Probaly, yes. It's more likely that you aren't allocating enough memory 
somewhere (or that you are overwriting memory for one structure with 
data from another).


Jonas





More information about the fpc-pascal mailing list