Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / customdrawn / 2012-07

Rangecheck error

7 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Michael Schnell

I am still watching this, hoping that I once can create a working "Custom drawn" project.

I still can create and display an empty form (supposedly because I did fix some lines that created range check errors due to erroneous type definitions in some units.

I still get (unfixed) Range check errors as soon as I place any elements on the form.

e.g. this is seen when I have a button on the form. It is not seem to be due to erroneous type definitions.

TTInterp Line 481:
    exc.opcode := exc.Code^[exc.IP];

Thanks,
-Michael

Reply by email

Felipe Monteiro de Carvalho
to Michael Schnell
Michael Schnell wrote
I still can create and display an empty form (supposedly because I did fix some lines that created range check errors due to erroneous type definitions in some units.

Could you send me a patch?

I still get (unfixed) Range check errors as soon as I place any elements on the form.

This is very strange. A lot of people use LCL-CustomDrawn and I never heard anyone else complain. Why do you set range checking?

Show quoted text 5 lines
e.g. this is seen when I have a button on the form. It is not seem to be due to erroneous type definitions. TTInterp Line 481: exc.opcode := exc.Code^[exc.IP];

In which unit?

Felipe Monteiro de Carvalho

Reply by email

Michael Schnell
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote
Could you send me a patch?

trying to remember which file(s) I modified ..... :-( I'll try to look this up. (I'm not yet up to speed with svn but trying :-) ) ...

OK. See below. Not sure which changes in fact did the trick for the form and which were done trying to debug and to get e.g TLable running. And which might be shown due to me not merging and the repository getting changes.

I do remember the Get_Long / Get_ULong issue. Here I definitely found that the types Long and ULong were used in a sloppy way, resulting in a range check condition when an ULong value > $7FFFFFFF is assigned to a signed Long.

Similar with PtrInt vs THandle.

Maybe you want to take a look at my old posts on this in the this forum.....

-Michael

TTInterp Line 481: exc.opcode := exc.Code^[exc.IP]; In which unit?

(******************************************************************* *
* TTInterp.pas 2.0 *
* TrueType bytecode intepreter.
*

IFAIR, all these range check problems are due to glitches in these Font related functions that seem to be implemented in a way that relies on range check beeing off. I don't think this is a good idea and I think that these issues should be fixed by using the correct types and/or explicit typecasts when appropriate.

-Michael

svn diff:
------------------------------------------------------------------------ --- components/lazutils/ttload.pas (revision 37854) +++ components/lazutils/ttload.pas (working copy) @@ -56,6 +56,8 @@

  implementation

+{$R-}
+

  uses TTError, TTMemory, TTFile;
    (* Composite glyph decoding flags *)
@@ -248,25 +250,27 @@
        exit;
      end;
-    with face^ do
-    begin
+//    with face^ do
+//    begin
-      numTables := tableDir.numTables;
+      face^.numTables := tableDir.numTables;

- if Alloc( dirTables, numTables * sizeof( TTableDirEntry ) ) or
- TT_Access_Frame( 16 * numTables ) then exit;
+ if Alloc( face^.dirTables, face^.numTables * sizeof( TTableDirEntry ) ) or
+ TT_Access_Frame( 16 * face^.numTables ) then exit;

-      for n := 0 to numTables-1 do with dirTables^[n] do
+      for n := 0 to face^.numTables-1 do
        begin
-        Tag        := GET_ULong;
-        Checksum   := GET_ULong;
-        Offset     := GET_Long;
-        Length     := Get_Long;
+        face^.dirTables^[n].Tag        := GET_ULong;
+        face^.dirTables^[n].Checksum   := GET_ULong;
+//        face^.dirTables^[n].Tag        := GET_Long;
+//        face^.dirTables^[n].Checksum   := GET_Long;
+        face^.dirTables^[n].Offset     := GET_Long;
+        face^.dirTables^[n].Length     := Get_Long;
        end;
        TT_Forget_Frame;
-   end;
+//   end;
     {$IFDEF FREETYPE_DEBUG} Writeln('loaded'); {$ENDIF}

Index: components/lazutils/lazfreetype.pas
=================================================================== --- components/lazutils/lazfreetype.pas (revision 37854) +++ components/lazutils/lazfreetype.pas (working copy) @@ -464,6 +464,8 @@
TTGLoad,

    TTRaster;

+{$R-}
+
(*****************************************************************) (* *)
(* *)
Index: components/lazutils/ttobjs.pas
=================================================================== --- components/lazutils/ttobjs.pas (revision 37854) +++ components/lazutils/ttobjs.pas (working copy) @@ -796,6 +796,8 @@

+{$R-}
+

  const
    objs_face_class     : TCache_Class
                        = (object_size: sizeof(TFace);

Index: components/lazutils/ttmemory.pas
=================================================================== --- components/lazutils/ttmemory.pas (revision 37854) +++ components/lazutils/ttmemory.pas (working copy) @@ -64,6 +64,7 @@

  uses TTTypes;
+{$R-}
  {$I TTCONFIG.INC}
  type

Index: components/lazutils/ttfile.pas
=================================================================== --- components/lazutils/ttfile.pas (revision 37854) +++ components/lazutils/ttfile.pas (working copy) @@ -48,6 +48,8 @@

  {$I TTCONFIG.INC}
+{$R-}
+
  uses TTTypes,
       TTError;

Index: lcl/interfaces/customdrawn/customdrawndefines.inc =================================================================== --- lcl/interfaces/customdrawn/customdrawndefines.inc (revision 37854) +++ lcl/interfaces/customdrawn/customdrawndefines.inc (working copy) @@ -3,6 +3,12 @@

  {$modeswitch objectivec1}{$H+}// modeswitch seams to deactivate H+
  {$endif}

+
+
+{$define CD_Debug_TTF}
+
+
+

  // For now default to Android for arm-linux,
  // because LCL-CustomDrawn is our main Android widgetset.
  // Remove this when Android gets it's own target

Index: lcl/interfaces/fpgui/fpguiobject.inc
=================================================================== --- lcl/interfaces/fpgui/fpguiobject.inc (revision 37854) +++ lcl/interfaces/fpgui/fpguiobject.inc (working copy) @@ -150,7 +150,7 @@

  begin
    Timer := TFPGUITimer.Create(Interval, TimerFunc);
-  Result := PtrInt(Timer);
+  Result := THandle(Timer);
  end;
  {------------------------------------------------------------------------------

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/customdrawn/attachments/20120703/f78bcad6/attachment.html>

Reply by email

Michael Schnell
to Felipe Monteiro de Carvalho: Could you send me a patch? This is very strange. A lot of people use LCL-CustomDrawn and…
Felipe Monteiro de Carvalho wrote
This is very strange. A lot of people use LCL-CustomDrawn and I never heard anyone else complain.

Maybe this only happens on Linux 32 Bit. Maybe in Windows there is nothing that triggers the problem, as the basic widgets used behave differently, and in 64 bit the range for the values always is sufficient. As you know, I in fact did locate at least two glitches in the source code that rather obviously result in range check errors when the values to be handled are appropriate.

Why do you set range checking?

I did not set it. In fact I don't even know how I should be able to set (or unset) it. I do suppose it is set on default (which I think is good to find exactly such problems as I am reporting right now.)

I just use the unmodified building process:

- get the current sources for ftp and Lazarus from the svn trunk
- compile fpc
- install fpc
- clean and make Lazarus
- start Lazarus
- create an "Application"
- set the Widget Type to Custom Drawn
- compile and run the blank Form -> works (due to the fixes I once did)
- drop a widget in the form (e.g. a TButton or a TLabel) -compile and run -> range check error.

-Michael

Reply by email

Michael Schnell
to Michael Schnell: trying to remember which file(s) I modified ..... :-( I'll try to look this up. (I'm not…

Hi Custom Drawers.

I deleted and re-downloaded the Lazarus trunk and after this I can't even run an empty form any more. It generates the said Rangecheck errors, so nothing seems to have been improved on that behalf since March.

.-Michael

Michael Schnell wrote 182 lines
On 07/03/2012 10:48 AM, Felipe Monteiro de Carvalho wrote: > Could you send me a patch? trying to remember which file(s) I modified ..... :-( I'll try to look this up. (I'm not yet up to speed with svn but trying :-) ) ... OK. See below. Not sure which changes in fact did the trick for the form and which were done trying to debug and to get e.g TLable running. And which might be shown due to me not merging and the repository getting changes. I do remember the Get_Long / Get_ULong issue. Here I definitely found that the types Long and ULong were used in a sloppy way, resulting in a range check condition when an ULong value > $7FFFFFFF is assigned to a signed Long. Similar with PtrInt vs THandle. Maybe you want to take a look at my old posts on this in the this forum..... -Michael > TTInterp Line 481: > exc.opcode := exc.Code^[exc.IP]; > In which unit? (******************************************************************* * * TTInterp.pas 2.0 * * TrueType bytecode intepreter. * IFAIR, all these range check problems are due to glitches in these Font related functions that seem to be implemented in a way that relies on range check beeing off. I don't think this is a good idea and I think that these issues should be fixed by using the correct types and/or explicit typecasts when appropriate. -Michael svn diff: ------------------------------------------------------------------------ --- components/lazutils/ttload.pas (revision 37854) +++ components/lazutils/ttload.pas (working copy) @@ -56,6 +56,8 @@ implementation +{$R-} + uses TTError, TTMemory, TTFile; (* Composite glyph decoding flags *) @@ -248,25 +250,27 @@ exit; end; - with face^ do - begin +// with face^ do +// begin - numTables := tableDir.numTables; + face^.numTables := tableDir.numTables; - if Alloc( dirTables, numTables * sizeof( TTableDirEntry ) ) or - TT_Access_Frame( 16 * numTables ) then exit; + if Alloc( face^.dirTables, face^.numTables * sizeof( TTableDirEntry ) ) or + TT_Access_Frame( 16 * face^.numTables ) then exit; - for n := 0 to numTables-1 do with dirTables^[n] do + for n := 0 to face^.numTables-1 do begin - Tag := GET_ULong; - Checksum := GET_ULong; - Offset := GET_Long; - Length := Get_Long; + face^.dirTables^[n].Tag := GET_ULong; + face^.dirTables^[n].Checksum := GET_ULong; +// face^.dirTables^[n].Tag := GET_Long; +// face^.dirTables^[n].Checksum := GET_Long; + face^.dirTables^[n].Offset := GET_Long; + face^.dirTables^[n].Length := Get_Long; end; TT_Forget_Frame; - end; +// end; {$IFDEF FREETYPE_DEBUG} Writeln('loaded'); {$ENDIF} Index: components/lazutils/lazfreetype.pas =================================================================== --- components/lazutils/lazfreetype.pas (revision 37854) +++ components/lazutils/lazfreetype.pas (working copy) @@ -464,6 +464,8 @@ TTGLoad, TTRaster; +{$R-} + (*****************************************************************) (* *) (* *) Index: components/lazutils/ttobjs.pas =================================================================== --- components/lazutils/ttobjs.pas (revision 37854) +++ components/lazutils/ttobjs.pas (working copy) @@ -796,6 +796,8 @@ +{$R-} + const objs_face_class : TCache_Class = (object_size: sizeof(TFace); Index: components/lazutils/ttmemory.pas =================================================================== --- components/lazutils/ttmemory.pas (revision 37854) +++ components/lazutils/ttmemory.pas (working copy) @@ -64,6 +64,7 @@ uses TTTypes; +{$R-} {$I TTCONFIG.INC} type Index: components/lazutils/ttfile.pas =================================================================== --- components/lazutils/ttfile.pas (revision 37854) +++ components/lazutils/ttfile.pas (working copy) @@ -48,6 +48,8 @@ {$I TTCONFIG.INC} +{$R-} + uses TTTypes, TTError; Index: lcl/interfaces/customdrawn/customdrawndefines.inc =================================================================== --- lcl/interfaces/customdrawn/customdrawndefines.inc (revision 37854) +++ lcl/interfaces/customdrawn/customdrawndefines.inc (working copy) @@ -3,6 +3,12 @@ {$modeswitch objectivec1}{$H+}// modeswitch seams to deactivate H+ {$endif} + + +{$define CD_Debug_TTF} + + + // For now default to Android for arm-linux, // because LCL-CustomDrawn is our main Android widgetset. // Remove this when Android gets it's own target Index: lcl/interfaces/fpgui/fpguiobject.inc =================================================================== --- lcl/interfaces/fpgui/fpguiobject.inc (revision 37854) +++ lcl/interfaces/fpgui/fpguiobject.inc (working copy) @@ -150,7 +150,7 @@ begin Timer := TFPGUITimer.Create(Interval, TimerFunc); - Result := PtrInt(Timer); + Result := THandle(Timer); end; {------------------------------------------------------------------------------ _______________________________________________ Customdrawn mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/customdrawn

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/customdrawn/attachments/20120828/a8ff3d3a/attachment.html>

Reply by email

Felipe Monteiro de Carvalho
to Felipe Monteiro de Carvalho
Michael Schnell wrote
An empty form works, when placing a button or a label, the other range check errors hit as I described at that time. :-(

Could you send the exact error?

I think it is caused by something that changed in FPC 2.7.1 as I have no problems with FPC 2.6.0 in all platforms

But I don't use this FPC version at the moment. I'd recommend you to make a patch and send it, like before.

thanks,

Felipe Monteiro de Carvalho

Reply by email