[fpc-pascal] How to get to Range Check Error location

Juha Manninen (gmail) juha.manninen62 at gmail.com
Sat Oct 2 15:07:36 CEST 2010


On Saturday 02 October 2010 12:21:20 Jonas Maebe wrote:
> Compile with -gl, or set a breakpoint on FPC_RANGEERROR

Forgot to tell, I compiled with "-gw -gh".
"-gw" should be as good as "-gl".
Now I tried with -gl but no luck. I get an Assembly window:
  http://koti.phnet.fi/juhamann/Lazarus/AssemblyRangeCheck.jpg
but no source lines.

For FPC_RANGEERROR, I found this in FTL system.inc:

  procedure fpc_rangeerror;[public,alias:'FPC_RANGEERROR']; compilerproc;
  begin
    HandleErrorFrame(201,get_frame);
  end;

I didn't even know there is such syntax in this language. 
Should I build the compiler with debug info?
I think I will leave it for now and debug Lazarus without -Cr.

The program (Lazarus) works when built without range checks. Maybe the errors 
are not "real" errors and could be solved by strict types.
Or, maybe the memory corruption happens so seldom that nobody notices.

When testing the Delphi converter I get many such errors, maybe because the 
input data is unpredictable.

In any case FPC should give better feedback to the user about range check 
errors. A RunError and an Assembly window are quite useless.


Regards,
Juha

P.S.
Because of "-gh" I am getting the following output always when closing 
Lazarus. Only the numbers change with Lazarus versions and compile options.

Likely it is not a "real" error. Vincent Snijders suspected it is a bug in the 
way heaptrc does its counting in a 64-bit system. In a 32-bit system it works.

Heap dump by heaptrc unit
4323916 memory blocks allocated : 939864995/951779128
4323916 memory blocks freed     : 939864995/951779128
0 unfreed memory blocks : 0
True heap size : 1048576
True free heap : 1924768
Should be : 1048576



More information about the fpc-pascal mailing list