Sign in Join

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

Mailing lists / lazarus / 2012-03

Trunk LCL-AggPas demo 1 gives segmentation fault

8 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Graeme Geldenhuys

Hi,

Can anybody else successfully run the AggPasInLCLDemo1 demo (an LCL-AggPas demo) under 64-bit Linux?

I've got the latest Lazarus Trunk and using FPC 2.6.1 under 64-bit Ubuntu 10.04. Running the demo gives me a near instant crash. Ignoring the error gives me a blank form. No AggPas painting $ gdb ./AggPasInLCLDemo1
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from
/opt/git/lazarus_argon/components/aggpas/lazarus/example/AggPasInLCLDemo1...done. (gdb) break fpc_raiseexception
Breakpoint 1 at 0x455ea0
(gdb) run
Starting program:
/opt/git/lazarus_argon/components/aggpas/lazarus/example/AggPasInLCLDemo1 [Thread debugging using libthread_db enabled]
TForm1.FormCreate ../../verdana.ttf True

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff5908595 in FT_Render_Glyph () from /usr/lib/libfreetype.so.6 (gdb) bt
#0 0x00007ffff5908595 in FT_Render_Glyph () from /usr/lib/libfreetype.so.6 #1 0x000000000078cb4c in PREPARE_GLYPH (this=..., GLYPH_CODE=72) at ../../../../../lazarus/components/aggpas/src/agg_font_freetype.pas:1283 #2 0x000000000076b883 in GLYPH (this=..., GLYPH_CODE=72) at ../../../../../lazarus/components/aggpas/src/agg_font_cache_manager.pas:465 #3 0x0000000000747cab in AGGTEXTOUT (this=0x7ffff7e0ec30, X=10, Y=49, STR=0xa32ce0 "LCL and AggPas", ROUNDOFF=false, DDX=0, DDY=0) at ../../../../../lazarus/components/aggpas/src/agg_fpimage.pas:2941 #4 0x000000000074b9d7 in AGGTEXTOUT (this=0x7ffff7e0ec30, X=10.5, Y=30.5, STR=0xa32ce0 "LCL and AggPas", ROUNDOFF=false, DDX=0, DDY=0) at ../../../../../lazarus/components/aggpas/src/agg_lcl.pas:452 #5 0x0000000000742779 in DOTEXTOUT (this=0x7ffff7e0ec30, X=10, Y=30, STR=0xa32ce0 "LCL and AggPas")
at ../../../../../lazarus/components/aggpas/src/agg_fpimage.pas:1480 #6 0x000000000053ae01 in
FPCANVAS$_$TFPCUSTOMCANVAS_$__$$_TEXTOUT$LONGINT$LONGINT$ANSISTRING () #7 0x00000000004827fe in FORMCREATE (this=0x7ffff7e0d630, SENDER=0x7ffff7e0d630) at unit1.pas:66
#8 0x000000000046d779 in DOCREATE (this=0x7ffff7e0d630) at ../../../lazarus/lcl/include/customform.inc:863 #9 0x000000000046ba9d in AFTERCONSTRUCTION (this=0x7ffff7e0d630) at ../../../lazarus/lcl/include/customform.inc:79
---Type <return> to continue, or q <return> to quit--- #10 0x0000000000474160 in CREATE (this=0x7ffff7e0d630, vmt=0x1, THEOWNER=0x7ffff7e05050)
at ../../../lazarus/lcl/include/customform.inc:2956 #11 0x000000000047ea27 in CREATEFORM (this=0x7ffff7e05050, INSTANCECLASS=0xa32270, REFERENCE=0)
at ../../../lazarus/lcl/include/application.inc:2166 #12 0x0000000000445935 in main () at AggPasInLCLDemo1.lpr:17 (gdb)
---------------------------------------------

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Alexander Klenin
to Graeme Geldenhuys
Graeme Geldenhuys wrote
I've got the latest Lazarus Trunk and using FPC 2.6.1 under 64-bit Ubuntu 10.04. Running the demo gives me a near instant crash. Ignoring the error gives me a blank form. No AggPas painting occurs at all.
Show quoted text 8 lines
#4 ?0x000000000074b9d7 in AGGTEXTOUT (this=0x7ffff7e0ec30, X=10.5, Y=30.5, ? ?STR=0xa32ce0 "LCL and AggPas", ROUNDOFF=false, DDX=0, DDY=0) ? ?at ../../../../../lazarus/components/aggpas/src/agg_lcl.pas:452 #5 ?0x0000000000742779 in DOTEXTOUT (this=0x7ffff7e0ec30, X=10, Y=30, ? ?STR=0xa32ce0 "LCL and AggPas") ? ?at ../../../../../lazarus/components/aggpas/src/agg_fpimage.pas:1480 #6 ?0x000000000053ae01 in FPCANVAS$_$TFPCUSTOMCANVAS_$__$$_TEXTOUT$LONGINT$LONGINT$ANSISTRING ()

This may or may not help, but I have carried the patch below in my local copy for a few years already.
I vaguely remember the symthoms to be the same, but I am on Windows, and it was a long time ago.

Index: src/agg_fpimage.pas
=================================================================== --- src/agg_fpimage.pas (revision 35880)
+++ src/agg_fpimage.pas (working copy)
@@ -3483,10 +3483,10 @@
end;

 procedure TAggFPFont.SetAggHeight(const AValue: double);
-{$IFDEF AGG2D_USE_FREETYPE}
+//{$IFDEF AGG2D_USE_FREETYPE}
 var
   c: TAggFPCanvas;
-{$ENDIF}
+//{$ENDIF}
 begin
   if FAggHeight=AValue then exit;
   FAggHeight:=AValue;
@@ -3498,7 +3498,11 @@
   else
     c.m_fontEngine.height_(c.AggWorldToScreen(FAggHeight ) );
   {$ELSE}
-  // ToDo
+  c:=TAggFPCanvas(Canvas);
+  if FAggCache = AGG_VectorFontCache then
+    c.m_fontEngine.height_(FAggHeight )
+  else
+    c.m_fontEngine.height_(c.AggWorldToScreen(FAggHeight ) );
   {$ENDIF}
 end;
Alexander S. Klenin

Reply by email

Graeme Geldenhuys
to Alexander Klenin
Alexander Klenin wrote
This may or may not help, but I have carried the patch below in my local copy for a few years already.

Thanks, but that made no difference. I can confirm that it is related to font handling. If I comment out the the font loading and drawing code in demo 1, then the demo runs fine, and I see the two circles being painted.

I'm trying to track down the issue further, but so far I have reviewed all the freetype code, and nothing stands out as immediately wrong. :-/

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Graeme Geldenhuys
to Graeme Geldenhuys
Graeme Geldenhuys wrote
I'm trying to track down the issue further, but so far I have reviewed all the freetype code, and nothing stands out as immediately wrong.

OK, the crash occurs on line 1283 of agg_font_freetype.pas unit. It is when it references m_cur_face.glyph that the error occurs. It sees m_cur_face.glyph is pointing to garbage, and then FT_Render_Glyph() chokes on it.

Strangely enough, loading the m_cur_face structure via the FreeType API never gave any problems though.

Anybody else that can put a eyeball in this piece of code? I think I've been staring at it too long, and am missing something obvious now.

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Henry Vermaak
to Graeme Geldenhuys
Graeme Geldenhuys wrote
Anybody else that can put a eyeball in this piece of code? I think I've been staring at it too long, and am missing something obvious now.

Why is FT_GlyphSlot a packed record in the aggpas sources? It's not a packed record in the c header (at least on my system), so they should use {$packrecords c) and a normal record.

Henry

Reply by email

Henry Vermaak
to Henry Vermaak
Henry Vermaak wrote 8 lines
On 12/03/12 14:27, Graeme Geldenhuys wrote: > Anybody else that can put a eyeball in this piece of code? I think > I've been staring at it too long, and am missing something obvious > now. Why is FT_GlyphSlot a packed record in the aggpas sources? It's not a packed record in the c header (at least on my system), so they should use {$packrecords c) and a normal record.

This goes for all their records. A quick look into the fpc sources reveals that they use {$packrecords c}. I presume it's a bit too much work to change aggpas to use the fpc freetype interface?

Henry

Reply by email

Graeme Geldenhuys
to Henry Vermaak: Why is FT_GlyphSlot a packed record in the aggpas sources? It's not a packed record in…
Henry Vermaak wrote
Why is FT_GlyphSlot a packed record in the aggpas sources? ?It's not a packed record in the c header (at least on my system), so they should use {$packrecords c) and a normal record.

Funny you mention that. 5 minutes before I had to leave work, I noticed the same thing. I modified the AggPas freetype interface unit using {$packrecords c} instead, and it did then load the Glyph information correctly (which was rubbish before). I didn't have enough time to test the Text painting, but at least the data structure contained valid information - so it is progress and heading in the right direction. :-) I'll test further tomorrow at work where I have a 64-bit system.

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Graeme Geldenhuys
to Henry Vermaak: This goes for all their records. A quick look into the fpc sources reveals that they use…
Henry Vermaak wrote
?I presume it's a bit too much work to change aggpas to use the fpc freetype interface?

The fpc freetype interface unit could be used, but AggPas (as far as I can see), has a more complete translation of the C header. But that is not the only freetype code in AggPass - there is also a freetype glyph cache manager implementation.

Why is the freetype header information under the FPC packages/fcl-images/ directory, and not eg: packagse/libfreetype/ like many of the other C header translations?

Anyway, once I get AggPas working in it's current implementation with 32-bit and 64-bit Linux, then I'll take a look at using more FPC units and type definitions where feasible.

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email