Re: Bug in String Height



On Wed, 16 May 2001, Pavel Rousnak wrote:


Hi all!

I'm using Gtk 0.7006.

There is a bug in Gtk::Gdk::Font::string_height() causing 'segmentation fault'
when I call this function.
At the same time text_height() works perfectly.

Examining Gtk.xs I've found out the following:
There is a line:
 RETVAL = gdk_text_height(font, SvPV(text, tlen), ix==1?len:tlen); 
which is buggy (in my opinion, of course). 
Compiler doesn't guarantee that parameters are calculating in order they 
appear in the list (from left to right). 
My gcc 2.96, for example, passes them in opposite order, so function
gdk_text_height will be passed undefined value as third parameter because
it is pushed to the stack earlier than SvPV is called.


Just my uneducated opinion but I think that from the definition of C
SvPv(text, tlen) _must_ be evaluated before gdk_text_height is called. If
your compiler does not do that then it is buggy, and it is not the fault
of the Perl/Gtk+ bindings.

Whether SvPv(text, tlen) is evaluated before "ix==1?len:tlen" or not is
left to the discretion of the compiler, but otherwise arguments to
functions are processed before the functions themselves.
 
Regards,

        Shlomi Fish

It seems to me there are more functions with the same bug (at least 
gdk_string_extents() contains similar line).


-- 

Best regards
Pavel.



_______________________________________________
gtk-perl-list mailing list
gtk-perl-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-perl-list




----------------------------------------------------------------------
Shlomi Fish        shlomif vipe technion ac il 
Home Page:         http://t2.technion.ac.il/~shlomif/
Home E-mail:       shlomif techie com

A more experienced programmer does not make less bugs. He just realizes
what went wrong more quickly.






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]