Hi,
I would like to re-open netsnmp Bug "[ 1868278 ] A bug in python useing
netsnmp.snmpwalk".

That's because cited patch (
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=497656 ) was addressing a
seg fault.

I did some tests in order to find the memory leak, I hope it can be avoided by
applying the following patch:

--- python/netsnmp/client_intf.c
+++ python/netsnmp/client_intf.c
@@ -1778,7 +1778,7 @@
PyObject *varlist;
PyObject *varbind;
PyObject *val_tuple = NULL;
- PyObject *varbinds;
+ PyObject *varbinds = NULL;
int varlist_len = 0;
int varlist_ind;
netsnmp_session *ss;
@@ -2003,14 +2003,13 @@
(len ? Py_BuildValue("s#", str_buf, len) :
Py_BuildValue("")));

- Py_DECREF(varbind);
-
} else {
/* Return None for this variable. */
_PyTuple_Resize(&val_tuple, result_count+1);
PyTuple_SetItem(val_tuple, result_count++, Py_BuildValue(""));
printf("netsnmp_walk: bad varbind (%d)\n", varlist_ind);
}
+ if(varbind) Py_DECREF(varbind);
}
/* reuse the response as the next pdu to send */
pdu = snmp_pdu_create(SNMP_MSG_GETNEXT);
@@ -2036,6 +2035,7 @@
}

done:
+ if(varbinds) Py_DECREF(varbinds);
SAFE_FREE(oid_arr);
return (val_tuple ? val_tuple : Py_BuildValue(""));
}

I'm not experienced with Python C API but I think the root cause was a missing
Py_DECREF on some PyObjects.

I suggest to test the patch to verify it is not breaking anything.

Thanks and Regards.

Gabriele Messineo

PS: I submitted a bug report in Debian toward the package libsnmp-python:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=503293

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.p...r_id=100&url=/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/...et-snmp-coders