[rrd-developers] rrd_graph.c crashed on right Y-axis with SI units

Martin Pelikan martin.pelikan at gmail.com
Sun Aug 12 15:58:56 CEST 2012


Hi!

I was just trying to make rrdtool 1.4.7 from Gentoo to make throughput graphs
in bps on the left axis and in Bps on the right one, when it suddenly crashed:

Program terminated with signal 11, Segmentation fault.
#0  0xb710c3dd in vfprintf () from /lib/libc.so.6
(gdb) where
#0  0xb710c3dd in vfprintf () from /lib/libc.so.6
#1  0xb712e525 in vsprintf () from /lib/libc.so.6
#2  0xb7113dcc in sprintf () from /lib/libc.so.6
#3  0xb771bdee in draw_horizontal_grid (im=im at entry=0xbfefb710) at rrd_graph.c:2103
#4  0xb771f0ee in grid_paint (im=im at entry=0xbfefb710) at rrd_graph.c:2678
#5  0xb772586b in graph_paint (im=im at entry=0xbfefb710) at rrd_graph.c:3714
#6  0xb7725abc in rrd_graph_v (argc=argc at entry=25, argv=argv at entry=0xbfefe998) at rrd_graph.c:4003
#7  0xb7725c86 in rrd_graph (argc=argc at entry=25, argv=argv at entry=0xbfefe998, prdata=prdata at entry=0xbfefe7b4, xsize=xsize at entry=0xbfefe7b8, 
    ysize=ysize at entry=0xbfefe7bc, stream=stream at entry=0x0, ymin=ymin at entry=0xbfefe7c0, ymax=ymax at entry=0xbfefe7c8) at rrd_graph.c:3883
#8  0x0804ad04 in HandleInputLine (argc=26, argv=0xbfefe994, out=0xb7266960 <_IO_2_1_stderr_>) at rrd_tool.c:871
#9  0x08049303 in main (argc=26, argv=0xbfefe994) at rrd_tool.c:521

(gdb) print draw_horizontal_grid::im->second_axis_format
$1 = "%6.2lf %s"


Okay, then I decided I'll try to see the latest development version if that's
been fixed.  Unfortunately, after checking out the SVN stuff, autocrap seemed
to have created itself yet another problem it wasn't able to solve:


$ ./autogen.sh
... (omitted) ...
configure.ac:464: warning: AC_LANG_CONFTEST: no AC_LANG_SOURCE call detected in body
../../lib/autoconf/lang.m4:193: AC_LANG_CONFTEST is expanded from...
../../lib/autoconf/general.m4:2661: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2678: AC_LINK_IFELSE is expanded from...
../../lib/m4sugar/m4sh.m4:639: AS_IF is expanded from...
../../lib/autoconf/general.m4:2661: _AC_LINK_IFELSE is expanded from...
../../lib/autoconf/general.m4:2678: AC_LINK_IFELSE is expanded from...
configure.ac:464: the top level
bindings/tcl/Makefile.am:31: error: 'pkglibdir' is not a legitimate directory for 'SCRIPTS'
bindings/tcl/Makefile.am:30: error: 'pkglibdir' is not a legitimate directory for 'DATA'
autoreconf-2.69: automake failed with exit status: 1

$


Anyway, I wrote a patch against 1.4.7 that works for me, but I'm not entirely
confident on whether this is the desired behavior for everyone.  It enables
unit scaling just the same way as on the left axis, and works with %s.

Oh, my script was pretty simple, on default output from Damien Miller's flowd:

#/bin/sh
TOOL=/home/m/src/rrdtool-1.4.7/src/rrdtool
START=`date -d "2012-06-05 04:00" +%s`

${TOOL} graph vole.png --imgformat PNG -w 600 -h 400    \
        -s ${START} -e start+1d                 \
        --right-axis 0.125:0 --right-axis-format="%6.2lf %s"    \
        DEF:tcpbts=moje.rrd:tcp_bytes:AVERAGE   \
        DEF:udpbts=moje.rrd:udp_bytes:AVERAGE   \
        DEF:up=moje.rrd:udp_packets:AVERAGE     \
        DEF:tb=moje.rrd:tcp_bytes:AVERAGE       \
        CDEF:icmpbts=tb,-1,*                    \
        CDEF:udppkt=up,-1,*                     \
        AREA:tcpbts#ff0000:"TCP bytes"          \
        AREA:udpbts#00ff00:"UDP bytes"          \
        LINE1:udppkt#0000ff:"UDP packets"       \
        LINE1:icmpbts#00FFFF:"ICMP bytes"       \


I have absolutely zero intentions on even trying to fix anything related
to GNU autohell, but if the development version will work one day, I can
provide a patch to a more recent version of rrdtool.

Any more questions?  Can this go in, or at least some other fix?
by the way, thanks a lot for this software!
--
Martin Pelikan




--- rrd_graph.c.old     2012-01-24 11:08:48.000000000 +0100
+++ rrd_graph.c 2012-08-12 15:20:32.000000000 +0200
@@ -2086,13 +2086,11 @@ int draw_horizontal_grid(
                 if (im->second_axis_scale != 0){
                         char graph_label_right[100];
                         double sval = im->ygrid_scale.gridstep*(double)i*im->second_axis_scale+im->second_axis_shift;
-                        if (im->second_axis_format[0] == '\0'){
-                            if (!second_axis_magfact){
-                                double dummy = im->ygrid_scale.gridstep*(double)(sgrid+egrid)/2.0*im->second_axis_scale+im->second_axis_shift;
-                                auto_scale(im,&dummy,&second_axis_symb,&second_axis_magfact);
-                            }
-                            sval /= second_axis_magfact;
+                        if (im->unitsexponent) {
+                            auto_scale(im,&sval,&second_axis_symb,&second_axis_magfact);
+                        }
 
+                        if (im->second_axis_format[0] == '\0'){
                             if(MaxY < 10) {
                                 sprintf(graph_label_right,"%5.1f %s",sval,second_axis_symb);
                             } else {
@@ -2100,7 +2098,7 @@ int draw_horizontal_grid(
                             }
                         }
                         else {
-                           sprintf(graph_label_right,im->second_axis_format,sval);
+                           sprintf(graph_label_right,im->second_axis_format,sval,second_axis_symb);
                         }
                         gfx_text ( im,
                                X1+7, Y0,



More information about the rrd-developers mailing list