I believe this is related to a bug reported to the archive:
 
http://www.mail-archive.com/[EMAIL PROTECTED]/msg01291.html
 
I was wondering if there is already plan to fix the bug without me having to implement the workaround (reference count on allocated data_context)?
 
Thanks,
Trang
 


From: Trang Nguyen
Sent: Wednesday, October 20, 2004 12:40 PM
To: '[EMAIL PROTECTED]'
Subject: RE: Snmpd core dump

I found out that the free_data_context is callled twice on the same address (from netsnmp_table_iterator_helper_handler). The second time, it core dumps because the memory has been freed. A standard walk does not produce this behavior. Can someone give me clues on why this might be happening?
 
Thanks,
Trang
 
 
-----------------------
I am using Castlerock to test my snmp agent. I have no problems to perform walk, set, get, getnext on my agent, but when I try a "viewTable" on mh table, it is core dumping.
The reason seems to be that my custom table handler (routeTable_handler) is not invoked only in this scenario. Instead, netsnmp_table_iterarator_helper_handler is called instead, and I don't understand the reason why.
 
I would really appreciate some help.

Thanks,
Trang
 
 
Here is the stack trace before the core dump occurs:

#0 0x00000002012f4070 in kill () from /lib/libc.so.5

#1 0x00000002012eaec9 in raise () from /lib/libc.so.5

#2 0x00000002013507b6 in abort () from /lib/libc.so.5

#3 0x000000020134f27e in tcflow () from /lib/libc.so.5

#4 0x000000020134f297 in tcflow () from /lib/libc.so.5

#5 0x0000000201350500 in realloc () from /lib/libc.so.5

#6 0x000000020134fc55 in tcflow () from /lib/libc.so.5

#7 0x000000020134fe15 in free () from /lib/libc.so.5

#8 0x00000002014af04b in routeTable_data_free (data="" iinfo=0x712480)

at routeTable/routeTable_access.cpp:203

#9 0x000000020094c1fa in netsnmp_table_iterator_helper_handler () from /usr/local/lib/libnetsnmphelpers.so.6

#10 0x00000002006422fe in netsnmp_call_handler () from /usr/local/lib/libnetsnmpagent.so.6

#11 0x0000000200642629 in netsnmp_call_next_handler () from /usr/local/lib/libnetsnmpagent.so.6

#12 0x0000000200950b7d in table_helper_handler () from /usr/local/lib/libnetsnmphelpers.so.6

#13 0x00000002006422fe in netsnmp_call_handler () from /usr/local/lib/libnetsnmpagent.so.6

#14 0x0000000200642629 in netsnmp_call_next_handler () from /usr/local/lib/libnetsnmpagent.so.6

#15 0x00000002009449bd in netsnmp_bulk_to_next_helper () from /usr/local/lib/libnetsnmphelpers.so.6

#16 0x00000002006422fe in netsnmp_call_handler () from /usr/local/lib/libnetsnmpagent.so.6

#17 0x00000002006425af in netsnmp_call_handlers () from /usr/local/lib/libnetsnmpagent.so.6

#18 0x0000000200637cb0 in handle_var_requests () from /usr/local/lib/libnetsnmpagent.so.6

#19 0x000000020063927a in handle_pdu () from /usr/local/lib/libnetsnmpagent.so.6

#20 0x0000000200638ddd in netsnmp_handle_request () from /usr/local/lib/libnetsnmpagent.so.6

#21 0x0000000200636719 in handle_snmp_packet () from /usr/local/lib/libnetsnmpagent.so.6

#22 0x0000000200a95ac4 in _sess_process_packet () from /usr/local/lib/libnetsnmp.so.6

#23 0x0000000200a96f1e in _sess_read () from /usr/local/lib/libnetsnmp.so.6

#24 0x0000000200a96f71 in snmp_sess_read () from /usr/local/lib/libnetsnmp.so.6

#25 0x0000000200a95c50 in snmp_read () from /usr/local/lib/libnetsnmp.so.6

#26 0x00000000004048b5 in receive ()

#27 0x0000000000403e99 in main ()

 
----------------------------------------------------------------------------------------------------------------------------
Here's how I register my custom handler (and it all other cases, this is invoked).
 

my_handler = netsnmp_create_handler_registration("routeTable",

routeTable_handler,

routeTable_oid,

OID_LENGTH(routeTable_oid),

HANDLER_CAN_RWRITE);

if (!my_handler || !table_info || !iinfo) {

snmp_log(LOG_ERR, "malloc failed in initialize_table_routeTable");

return; /** Serious error. */

}

netsnmp_table_helper_add_indexes(table_info,ASN_INTEGER, /** index: routeEntryIndex */0);

table_info->min_column = 1;

table_info->max_column = 5;

iinfo->get_first_data_point = routeTable_get_first_data_point;

iinfo->get_next_data_point = routeTable_get_next_data_point;

iinfo->free_data_context = routeTable_data_free;

iinfo->free_loop_context = routeTable_loop_free;

iinfo->table_reginfo = table_info;

DEBUGMSGTL(("initialize_table_routeTable",

"Registering table routeTable as a table iterator\n"));

netsnmp_register_table_iterator(my_handler, iinfo);

Reply via email to