I think this patch fixes the bus error in async bulkwalk from perl. Can somebody review and test this patch to see if it can get into the distribution? (It works for me :-)
Explanation for patch. 1. The first patch removes snmp_free_pdu(pdu) from _bulkwalk_recv_pdu in the error return path. Note the note in the comment for the function: "Note that the caller is expected to free the pdu." This function is used in two cases: 1) called from snmp_bulkwalk in sync case. 2) async case: from main loop in snmp_read. In the async case, the pdu is always freed. Any error in this function means that the buffer will be free'd twice. 2. The change from dXSARGS to dSP in _bulkwalk_finish is because the callers to _bulkwalk_finish already has done a dXSARGS (which pops a mark from the mark stack). You can't do this twice unless pushing a mark on the stack in between. 3. The removal if SP -= items is neccessary because SP has already been reset by the caller by the dXSARGS. item is also not defined. 4. The change from break to goto err in snmp_bulkwalk is necessary to fulfill the invariant that the caller to _bulkwalk_recv_pdu must free the pdu. See change 1. Kind regards, Ole Bjørn. rocs3(obh) net-snmp 574$ cat patch.bus-error diff -cr net-snmp-5.3.pre4-orig/perl/SNMP/SNMP.xs net-snmp-5.3.pre4-obh/perl/SNMP/SNMP.xs *** net-snmp-5.3.pre4-orig/perl/SNMP/SNMP.xs Wed Oct 5 14:26:46 2005 --- net-snmp-5.3.pre4-obh/perl/SNMP/SNMP.xs Tue Nov 22 15:11:45 2005 *************** *** 2274,2281 **** return pix; err: - if (pdu) - snmp_free_pdu(pdu); return -1; } --- 2285,2290 ---- *************** *** 2301,2307 **** SV **err_str_svp = hv_fetch((HV*)SvRV(context->sess_ref), "ErrorStr", 8, 1); SV **err_num_svp = hv_fetch((HV*)SvRV(context->sess_ref), "ErrorNum", 8, 1); ! dXSARGS; async = SvTRUE(context->perl_cb); --- 2310,2316 ---- SV **err_str_svp = hv_fetch((HV*)SvRV(context->sess_ref), "ErrorStr", 8, 1); SV **err_num_svp = hv_fetch((HV*)SvRV(context->sess_ref), "ErrorNum", 8, 1); ! dSP; async = SvTRUE(context->perl_cb); *************** *** 2310,2317 **** ** items pushed onto the stack. For async, create a new array and push ** the references onto it. The array is then passed to the Perl callback. */ - if (!async) - SP -= items; DBPRT(1, (DBOUT "Bulwalk %s (saved %d/%d), ", okay ? "completed" : "had error", context->oid_saved, context->oid_total)); --- 2319,2324 ---- *************** *** 4120,4126 **** */ if ((i = _bulkwalk_recv_pdu(context, pdu)) <= 0) { DBPRT(2,(DBOUT "bulkwalk_recv_pdu() returned %d (error/empty)\n", i)); ! break; } /* Free the returned pdu. Don't bother to do this for the async --- 4127,4133 ---- */ if ((i = _bulkwalk_recv_pdu(context, pdu)) <= 0) { DBPRT(2,(DBOUT "bulkwalk_recv_pdu() returned %d (error/empty)\n", i)); ! goto err; } /* Free the returned pdu. Don't bother to do this for the async Ole Bjørn Hessen, NMS-IP, PF-Nett, Telenor Networks ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today Register for a JBoss Training Course. Free Certification Exam for All Training Attendees Through End of 2005. For more info visit: http://ads.osdn.com/?ad_idv28&alloc_id845&op=click _______________________________________________ Net-snmp-coders mailing list Net-snmp-coders@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/net-snmp-coders