[fpc-pascal] Segmentation Error using VideoBuf

Tomas Hajny XHajT03 at hajny.biz
Mon Jul 7 21:44:15 CEST 2014

On 3 Jul 14, at 3:44, Tomas Hajny wrote:
> On Wed, July 2, 2014 14:32, mokashe.ram wrote:

Hi again,

> >              I have done all my work with Free pascal but only one error
> > which still i am not able to fix is MEM as i tried all the options which
> > you
> > suggest me (heartly thanks for that) but still i am not Getting exect
> > solution for it.....
>  .
>  .
> I'm currently on holiday, but I'll have a look at your source after
> getting back home if noone else solves your issue earlier (feel free to
> remind me if you don't get any response if you don't get any response
> within one week from now).

Alright, I've checked it now:

1) As already pointed out by Mark, your source is not compilable 
although you claimed the opposite in your post. First, routines 
Mouse_Enabled, Show_Mouse and Hide_Mouse are neither known by your 
source nor needed in those places because unit Video already takes 
care about the mouse cursor as needed on the particular platform 

2) As also mentioned by Mark, you should provide a test program 
rather than a unit, or you should add a small test program using the 
unit if absolutely necessary (to be honest, I don't understand why 
the compiler refuses to compile it if changing it from a unit to a 
program by removing "interface" and "implementation" keywords and 
moving the "uses" section to the beginning - it complains about 
constructor having to be used only for methods, although exactly the 
same source is compiled happily in a unit???). Anyway, I changed

3) After fixing issues mentioned above, the compiler emits exactly 
one warning when compiling the code. This warning (conversion about 
pointers and ordinals not being portable) helps to locate something 
that could indeed lead to a segmentation error (or at least certainly 
not working as expected). Line  
"current_location^.code:=word(@VideoBuf^[P]);" should be (probably?) 
changed to "current_location^.code:=VideoBuf^[P];" if it aims to read 
character and attributes at the specified screen location. BTW, if I 
understand the intention of the code, it's terribly inefficient, but 
that's another thing.

4) The test part (originally located in the initialization part of 
the unit, but moved to a test program by me) should be changed so 
that it waits for some user interaction before you the final 
DoneVideo call, because this call may destroy whatever you did 
before. You should insert a call to something like ReadLn (waiting 
for Enter) or ReadKey (waiting for any "regular" key) before the 
DoneVideo call to see what the test does. Finally, the parameters of 
Error_Message.Initialise should be probably better changed for a 
bigger window size. If I did that, I could see a rectangle displayed. 
It does not exactly what you expect it to do, but you should be 
probably able to debug the issue from that point (_if_ you understand 
what it does - frankly, I'm not completely convinced about that).


More information about the fpc-pascal mailing list