Hi,
I tested my agent to check memory leaks on agentx subagent for SET requests.
Unfortunately, with my patch, still memory leaks occur.
So, I dug into it Yesterday.
And, I found out no crash and no memory leak solution(?) for subagent's SET memory
leak.
Actually, Mr. rstory already found out the way of avoiding memory leak.
"in the function save_set_cache() in agent/snmp_agent.c,
comment out the line 'asp->pdu->variables = NULL;'."
But, as Mr. rstory already mentioned, this solution causes crash. So, I traced it.
And, I found that
subagent crashed in function netsnmp_old_api_helper() of file helpers/old_api.c.
In file helpers/old_api.c, there is a definition '#define MIB_CLIENTS_ARE_EVIL 1'
I have no idea what is the meaning of this definition, but, it seems like for debug or
something
like that for me(it looks like not important)
So, I change it as '#define MIB_CLIENTS_ARE_EVIL 0'.
And then, crashes disappeared.
So, everybody, please test agentX SET request with following two changes
1. "in the function save_set_cache() in agent/snmp_agent.c,
comment out the line 'asp->pdu->variables = NULL;'." -- from Mr. rstory
2. '#define MIB_CLIENTS_ARE_EVIL 0'. -- from Won-Sik Kim
If somebody who know about definition MIB_CLIENTS_ARE_EVIL, let me know.
I am not sure it is OK or not if I change the MIB_CLIENTS_ARE_EVIL as 0.
By the way, above solution seem like fine for me until now.
Best regards,
Won-Sik Kim
----- Original Message -----
From: "Penz, Bernhard" <[EMAIL PROTECTED]>
To: "Won-Sik Kim" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, July 23, 2004 9:57 PM
Subject: RE: Bug report and Rqeust for confirm
Hi,
Could you also write a small test-Agent that checks if this also makes
the memory leaks for SET requests disappear (Bug 916605)? The leak there
is quite noticable, the agentx agent leaks about 4k for every SET.
I am going to check your patch next week under windows. It would be nice
if you can send a "diff -u" patch, that makes it easier for everybody to
apply your changes.
Regards
Bernhard
PS: Dunno if you can convince hotmail not to send HTML mails, but to
quote Dave:
Please - no HTML mail. Thanks
________________________________
From: Won-Sik Kim [mailto:[EMAIL PROTECTED]
Sent: Freitag, 23. Juli 2004 09:27
To: [EMAIL PROTECTED]
Subject: Bug report and Rqeust for confirm
Hi all,
I use net-snmp-5.1.1 on Linux with agentX for developing multi
device system.
I suffered from following three problems.
1. memory leak in master agent if manager sends many getbulk
requests at once.
2. crash of master agent happens time to time if manager sends
many getnext requests
3. some times, response from master agent slows down, but, if I
wait, if get back to normal status.
I already reported 1st problem. But, my question was too vague
to get response.
I debugged and traced net-snmp for a week, and find out which
source code causes 2nd problem(crash)
The bug was in function
netsnmp_check_outstanding_agent_requests(). (in file snmp_agent.c)
I only remove 1 line from the function. (line 24 in followed
source code) And, problem solved...
There was a possibility of referencing to freed
netsnmp_agent_session structure.
My explanations :
prev_asp is last asp (prev_asp = asp)
- line 9 in followed source code
But, if you trace function check_delayed_request(asp) - line
40 in followed source code
asp can be freed. (of course, pointer itself is not NULL)
This means, code "prev_asp->next = " can crash master agent.
asp is freed by this way. (trace sequence)
check_delayed_request(asp)
- line 40 in followed source code
netsnmp_wrap_up_request(asp)
netsnmp_remove_and_free_agent_snmp_session(asp)
free_agent_snmp_session(asp)
SNMP_FREE(asp);
As you know, SNMP_FREE(asp) does "asp = NULL", but, asp is
parsed as pointer, so this NULLing
can not help anything to code "if (prev_asp != NULL)" -
line 16 in followed source code
Finally, "prev_asp->next = asp->next" causes crash. (not always
though)
I was not sure what "prev_asp->next = asp->next" really does.
So, for test, I just removed it first.
And then, amazingly, this removing solved not only 2nd
problem(crash), but also 1st(memory leak),
and 3rd(slow down) !! And, there is no problem in get, getnext,
getbulk and set !!
After this change, no more crash, no more memory leak and no
more slow down.
Here are my requests.
1. Can somebody confirm my change ?
I just remove one line, but, I am wonder if this removing
causes other problem... (I can not find yet though)
2. If I am right, this change must be included in next
release(5.1.2)
I will wait for answer.
Best regards,
Won-Sik Kim
1 void
2 netsnmp_check_outstanding_agent_requests(void)
3 {
4 netsnmp_agent_session *asp, *prev_asp = NULL, *next_asp
= NULL;
5
6 /*
7 * deal with delegated requests
8 */
9 for (asp = agent_delegated_list; asp; prev_asp = asp, asp
= next_asp) {
10 next_asp = asp->next; /* save in case we clean up
asp */
11 if (!netsnmp_check_for_delegated(asp)) {
12
13 /*
14 * we're done with this one, remove from queue
15 */
16 if (prev_asp != NULL)
17 {
18 #if 0 /* by wonsikkim on 2004-07-22 to solve crash on
master agent problem */
19 /* Funny thing is by this change, other two major
problems also solved */
20 /* So, this change fix following three bugs at once.
*/
21 /* 1. master agent crash during processing a lot of
getnext requests */
22 /* 2. master agent slow down sometimes during
processing requests */
23 /* 3. memory leak if process a lot of getbulk
requests */
24 prev_asp->next = asp->next;
25 #endif
26 }
27 else
28 {
29 agent_delegated_list = asp->next;
30 }
31
32 /*
33 * check request status
34 */
35 netsnmp_check_all_requests_status(asp, 0);
36
37 /*
38 * continue processing or finish up
39 */
40 check_delayed_request(asp);
41 }
42 }