Hello,
so after digging around I've found a culprit. It is reallocation code in open_ofile - when number of items in the file does not match one collected, code goes and reallocates _buf0 with new size. But! act[x]->nr value is shared with multiple activites, so all must be reallocated (well, or one could remove this nr sharing - I have no idea what purpose it serves).

Hack to get things to work on my box is attached.

On my box problem was caused by change in the number of network adapters (activity 11 & 12 both share same nr[] index):

petr-dev3:/usr/src/debian/sysstat-9.0.1# valgrind ./sadc -F -L 1 1 -
==3127== Memcheck, a memory error detector.
==3127== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al.
==3127== Using LibVEX rev 1884, a library for dynamic binary translation.
==3127== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP.
==3127== Using valgrind-3.4.1-Debian, a dynamic binary instrumentation framework.
==3127== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
==3127== For more details, rerun with: -v
==3127==
Init: Activity 0 reports count 5
Init: Activity 1 reports count 1
Init: Activity 2 reports count 257
Init: Activity 3 reports count 1
Init: Activity 4 reports count 1
Init: Activity 5 reports count 1
Init: Activity 6 reports count 1
Init: Activity 7 reports count 1
Init: Activity 8 reports count 1
Init: Activity 9 reports count 0
Init: Activity 10 reports count 11
Init: Activity 11 reports count 6
Init: Activity 12 reports count 6
Init: Activity 13 reports count 1
Init: Activity 14 reports count 1
Init: Activity 15 reports count 1
Init: Activity 16 reports count 1
Init: Activity 17 reports count 1
Init: Activity 18 reports count 1
Init: Activity 19 reports count 1
Init: Activity 20 reports count 1
Init: Activity 21 reports count 1
Init: Activity 22 reports count 1
Init: Activity 23 reports count 1
Init: Activity 24 reports count 1
Init: Activity 25 reports count 1
Init: Activity 26 reports count 1
Init: Activity 27 reports count 1
Init: Activity 28 reports count 1
Init: Activity 29 reports count 5
Reset: Activity 0 reports count 5
Reset: Activity 1 reports count 1
Reset: Activity 2 reports count 257
Reset: Activity 3 reports count 1
Reset: Activity 4 reports count 1
Reset: Activity 5 reports count 1
Reset: Activity 6 reports count 1
Reset: Activity 7 reports count 1
Reset: Activity 8 reports count 1
Reset: Activity 9 reports count 0
Reset: Activity 10 reports count 12
Reset: Activity 11 reports count 8
Reset: Activity 12 reports count 8
Reset: Activity 13 reports count 1
Reset: Activity 14 reports count 1
Reset: Activity 15 reports count 1
Reset: Activity 16 reports count 1
Reset: Activity 17 reports count 1
Reset: Activity 18 reports count 1
Reset: Activity 19 reports count 1
Reset: Activity 20 reports count 1
Reset: Activity 21 reports count 1
Reset: Activity 22 reports count 1
Reset: Activity 23 reports count 1
Reset: Activity 24 reports count 1
Reset: Activity 25 reports count 1
Reset: Activity 26 reports count 1
Reset: Activity 27 reports count 1
Reset: Activity 28 reports count 1
Reset: Activity 29 reports count 5
==3127==
==3127== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 8 from 1)
==3127== malloc/free: in use at exit: 0 bytes in 0 blocks.
==3127== malloc/free: 87 allocs, 87 frees, 32,879 bytes allocated.
==3127== For counts of detected errors, rerun with: -v
==3127== All heap blocks were freed -- no leaks are possible.
petr-dev3:/usr/src/debian/sysstat-9.0.1#

                                                                Petr
--- sysstat-9.0.1/sadc.c.orig   2009-03-08 03:08:10.000000000 -0700
+++ sysstat-9.0.1/sadc.c        2009-06-02 20:27:46.000000000 -0700
@@ -714,12 +714,17 @@ void open_ofile(int *ofd, char ofile[])
                                                 */
                                                goto append_error;
                                        else {
+                                               int j;
+
                                                /*
                                                 * Force number of items 
(serial lines, network interfaces...)
                                                 * to that of the file, and 
reallocate structures.
                                                 */
                                                *act[p]->nr = file_act.nr;
-                                               SREALLOC(act[p]->_buf0, void, 
act[p]->msize * *act[p]->nr);
+                                               for (j = 0; j < NR_ACT; j++) {
+                                                       if (act[p]->nr == 
act[j]->nr)
+                                                               
SREALLOC(act[j]->_buf0, void, act[j]->msize * *act[j]->nr);
+                                               }
                                        }
                                }
                                /* Save activity sequence */

Reply via email to