patch for bus-error in async bulkwalk from perl

This is a discussion on patch for bus-error in async bulkwalk from perl within the SNMP Coders forums, part of the Networking and Network Related category; I think this patch fixes the bus error in async bulkwalk from perl. Can somebody review and test this patch ...


Go Back   Usenet Forums > Networking and Network Related > SNMP Coders

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-22-2005
Ole Bjørn Hessen
 
Posts: n/a
Default patch for bus-error in async bulkwalk from perl


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 -=3D 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=F8rn.


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/per=
l/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;
=20=20
err:
- if (pdu)
- snmp_free_pdu(pdu);
return -1;
=20=20
}
--- 2285,2290 ----
***************
*** 2301,2307 ****
SV **err_str_svp =3D hv_fetch((HV*)SvRV(context->sess_ref), "ErrorStr"=
, 8, 1);
SV **err_num_svp =3D hv_fetch((HV*)SvRV(context->sess_ref), "ErrorNum"=
, 8, 1);
=20=20
! dXSARGS;
=20=20
async =3D SvTRUE(context->perl_cb);
=20=20
--- 2310,2316 ----
SV **err_str_svp =3D hv_fetch((HV*)SvRV(context->sess_ref), "ErrorStr"=
, 8, 1);
SV **err_num_svp =3D hv_fetch((HV*)SvRV(context->sess_ref), "ErrorNum"=
, 8, 1);
=20=20
! dSP;
=20=20
async =3D SvTRUE(context->perl_cb);
=20=20
***************
*** 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 callb=
ack.
*/
- if (!async)
- SP -=3D items;
=20=20
DBPRT(1, (DBOUT "Bulwalk %s (saved %d/%d), ", okay ? "completed" : "ha=
d error",
context->oid_saved, context->oid_to=
tal));
--- 2319,2324 ----
***************
*** 4120,4126 ****
*/
if ((i =3D _bulkwalk_recv_pdu(context, pdu)) <=3D 0) {
DBPRT(2,(DBOUT "bulkwalk_recv_pdu() returned %d (error/emp=
ty)\n", i));
! break;
}
=20=20
/* Free the returned pdu. Don't bother to do this for the =
async
--- 4127,4133 ----
*/
if ((i =3D _bulkwalk_recv_pdu(context, pdu)) <=3D 0) {
DBPRT(2,(DBOUT "bulkwalk_recv_pdu() returned %d (error/emp=
ty)\n", i));
! goto err;
}
=20=20
/* Free the returned pdu. Don't bother to do this for the =
async



Ole Bj=F8rn 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_id=7628&alloc_id=16845&op=click
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/...et-snmp-coders
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 04:42 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0