Jean-Luc Dery (dery++at++Discreet.COM)
Tue, 20 Jan 1998 11:59:49 -0500
I've been trying to use pfFont for quite a while now and have always had memory
corruption problems . But I think I finally found the problem. My hypothesis is
the following:
There are two versions of the pfFont.h file; a GOOD pfFont.h used by Perfomer
to build their libraries and a BAD one that's in the Pf 2.1 developper's
distribution.
Here are my thoughs for concluding this UGLY allegation.
At first, I was using the pfdLoadFont loader provided with the libpfdu library;
everything worked just fine since it was probably compiled with the GOOD
pfFont.h file, until I tried to delete a pfFont object and reload another one.
This load/unload problem was due to a static pointer to a default material that
was deleted when the font was deleted; thus when loading another font, this
last one was referencing the deleted pfMaterial object. The workaround for this
is simply to never delete the first pfFont object loaded or to get the pointer
to this default material object via the pfFont/pfGeoSet API and add an extra
reference. But this is not very elegant.
But guess what, the pfdLoadFont source is given with the distribution, great,
let's fix this. And so I did. Everything would have worked just fine if I
didn't change the pfFont creation call from the C API to the CPP API. This is
where things got UGLY.
When I use pfNewFont call, memory allocation is done with the pf library
compiled with the GOOD pfFont.h file; when I use the new operator along with my
pfFont definition, memory allocation is done with my BAD pfFont.h file. This
can be demonstrated with the following lines:
pfFont* cFont = pfNewFont( pfGetSharedArena() );
printf( "C API font size = %d\n", pfMemory::getSize( cFont ) );
pfFont* cppFont = new( pfGetSharedArena() ) pfFont();
printf( "CPP API font size = %d\n", pfMemory::getSize( cppFont ) );
The output of this is:
C API font size = 76
CPP API font size = 4
Yeak ++at++?!&##?!
I think that this actually proves my hypothesis and I can tell you that Purify
was having pretty UGLY fun passing through the my "bug fixed" font loader.
So whatever you do when using pfFont, don't use the C++ API to instaciate your
pfFont; once instanciated, C API or C++ API should work.
Now, my concern is that we have derived a class from the pfFont class and we
can not use the C API to instanciate our font class. Does anyone out there have
a solution for this (patch, upgrade to 2.2, pfFont.h file overwrite, ...???).
This question is mostly the Performer developper team.
Is my hypothesis GOOD, BAD or just UGLY ?
I would greatly appreciate feedback on this and if I'm right, I can tell you
that this one was pretty nasty. But nevertheless, you folks are great and PF is
a great sw package, ... besides for fonts; but HA, who flies, drives or dives
with fonts.
Thanks in advance for your feedback,
Jean-Luc
-- _____________________________________________________________________________Jean-Luc Dery Discreet Logic System Engineer 10 Duke Street 3-D Graphics Technology Montreal (Quebec), Canada, H3C 2L7 Tel: (514) 954-7239 Email: dery++at++discreet.com Fax: (514) 393-0110 _____________________________________________________________________________ ======================================================================= List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/ Submissions: info-performer++at++sgi.com Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:35 PDT