[rrd-users] rrdtool 1.3.2 segmentation fault on rrdgraph

Tobias Oetiker tobi at oetiker.ch
Thu Sep 11 22:27:27 CEST 2008


René,

exactly ... this was my intention when I wrote this function as you
can see from the option rocessig code ... but somehow it did not
make it from my brain into C ... I would put the following:

Index: rrd_graph.c
===================================================================
--- rrd_graph.c (revision 1487)
+++ rrd_graph.c (working copy)
@@ -3678,11 +3678,17 @@
 static void
 rrd_set_font_desc (
     image_desc_t *im,int prop,char *font, double size ){
-    strncpy(im->text_prop[prop].font, font, sizeof(text_prop[prop].font) - 1);
-    im->text_prop[prop].font[sizeof(text_prop[prop].font) - 1] = '\0';
-    im->text_prop[prop].size = size;
-    im->text_prop[prop].font_desc =   pango_font_description_from_string( font );
-    pango_font_description_set_size(im->text_prop[prop].font_desc, size * PANGO_SCALE);
+    if (font){
+        strncpy(im->text_prop[prop].font, font, sizeof(text_prop[prop].font) - 1);
+        im->text_prop[prop].font[sizeof(text_prop[prop].font) - 1] = '\0';
+        im->text_prop[prop].font_desc = pango_font_description_from_string( font );
+    };
+    if (size > 0){
+        im->text_prop[prop].size = size;
+    };
+    if (im->text_prop[prop].font_desc && im->text_prop[prop].size ){
+        pango_font_description_set_size(im->text_prop[prop].font_desc, im->text_prop[prop].size * PANGO_SCALE);
+    };
 }

cheers
tobi


Today René GARCIA wrote:

> I think the problem can be fixed if you change the rrd_set_font_desc
> function code as this :
>
> static void
> rrd_set_font_desc (
>     image_desc_t *im,int prop,char *font, double size ){
>     if (font) {
>        strncpy(im->text_prop[prop].font, font,
> sizeof(text_prop[prop].font) - 1);
>        im->text_prop[prop].font[sizeof(text_prop[prop].font) - 1] = '\0';
>        im->text_prop[prop].font_desc =
> pango_font_description_from_string( font );
>     }
>     if (size>0) {
>        im->text_prop[prop].size = size;
>     }
>     pango_font_description_set_size(im->text_prop[prop].font_desc,
> im->text_prop[prop].size * PANGO_SCALE);
> }
>
> This function is called when decoding -n arguments. It is called once with
> font parameter set to NULL juste to set new size. Then it is called with
> size set to 0 to set font name. 1.3.2 function cant handle NULL and 0 as
> font and size parameter.
>
> René
>
>
> Le Jeu 11 septembre 2008 20:54, René GARCIA a écrit :
> > Raimund, you are right. This problem deals with -n option to change the
> > font. On each graph I create I have the following options to rrdgraph :
> >
> > -n "DEFAULT:8:Arial,Helvetica"
> > -n "TITLE:11:Arial,Helvetica Bold"
> > -n "LEGEND:7:Lucida Console,LucidaTypewriter,Courier"
> >
> >
> > When I remove these options I have no more segmentation fault on 1.3.2.
> >
> >
> > René
> >
> >
> >
> > Le Jeu 11 septembre 2008 14:55, Raimund Berger a écrit :
> >
> >> René GARCIA <rene at margar.fr> writes:
> >>
> >>
> >>
> >>> I've been using rrdtool 1.3.1 with no problem for a couple of
> >>> monthes. I
> >>> want tu upgrade to 1.3.2 to avoid the data corruption bug and to take
> >>> advantage of speed improvements (I have a lot of graphs to generate
> >>> every 5 minutes). I can compile 1.3.2 (and 1.3.2 svn snapshot) but I
> >>> can't make any rrdgraph call, without a segfault error. rrdupdate and
> >>>  rrdcreate work fine.
> >>>
> >>> I've upgraded to latests versions of cairo/pango/glib libraries but
> >>> the problem remains.
> >>>
> >>> I'm using perl 5.6.1 to invoke RRDs module. I have a lot of
> >>> dependancies with this version of perl on other projects so I would
> >>> like to keep it.
> >>>
> >>> I'm still using rrdtool 1.3.1.
> >>> Is anyone having the same problem ?
> >>>
> >>>
> >>
> >>
> >> I'm having the same problem. Tested it last week and from the core dump
> >>  I gathered it crashed it rrd_set_font_desc which apparently is a new
> >> function.
> >>
> >> Specifically, the 'font' pointer passed as 2nd param to
> >> strncpy(im->text_prop[prop].font, font, sizeof(text_prop[prop].font) -
> >> 1);
> >> apparently was a null pointer which went in there unchecked.
> >>
> >> Switched back to 1.3.0 cause I had other issues on hand at the
> >> time. Having a mixed cairo/pango library setup I couldn't convince
> >> myself to report the problem, cause I'd have felt obliged to further
> >> investigate.
> >>
> >>
> >> Maybe 1.3.2 wasn't a mere bugfix release?
> >>
> >>
> >>
> >> Regards, R.
> >>
> >>
> >>
> >> _______________________________________________
> >> rrd-users mailing list rrd-users at lists.oetiker.ch
> >> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
> >>
> >>
> >>
> >
> >
> > _______________________________________________
> > rrd-users mailing list rrd-users at lists.oetiker.ch
> > https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
> >
> >
>
>
> _______________________________________________
> rrd-users mailing list
> rrd-users at lists.oetiker.ch
> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>
>

-- 
Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland
http://it.oetiker.ch tobi at oetiker.ch ++41 62 775 9902 / sb: -9900


More information about the rrd-users mailing list