Menu

#1228 snmpget potential memory leakage

closed
nobody
apps (205)
5
2012-11-08
2004-10-20
Gizero
No

At moment I use version 5.1.1 (but what I report appear
to be valid in 5.2pre3 too). I was suspecting a memory
leakage in some of snmpget components and I made a
trivial modification in snmpget.c (see attached code),
in order to iterate snmpget funcionality and trying to
expose any potential leakage. Maybe I'm doing wrong but
what I see from 'top' or /proc process information is a
growing memory usage. In particular these are the
ever-growing figures:VmSize:

6312 kBVmRSS:
2160 kBVmData:
736 kB

Note that this test makes correct requests to the agent
(valid oid) and returned values are consistent.

I understand this could be a no-problem for a command
line tools like snmpget, but it is critical in my
project since I do provide snmpget functionalities
through a library function. What reported appear to be
present in both Linux and Win32 builds.

I'm not an expert in using debugging and profiling
tools, so any help will be appreciated to understand
(and possibly solve) this problem. I'd like to help in
tracking this thing down, if possible. Since I can't
state where the leakage is (if it is really so...) I'm
possibly reporting an already known problem: please
forgive me if so. ;-)

Andrea

Modified snmpget.c follows:
--
int
main(int argc, char *argv[]) {
while(1) {
_main(argc, argv);
}
}

int
_main(int argc, char *argv[]) {
<unmodified original="" main\(\)="">
}

Discussion

  • Gizero

    Gizero - 2004-10-20

    Logged In: YES
    user_id=1142754

    Addendum: forgot to state that the attached code
    misteriously seems to lose the community string for _main()
    calls after the first (any idea why this happens?). This
    brings to incomplete requests and authentication failures on
    the agent. Note that with this setup no leakage is visible.
    To have the leaking setup change the main() in order to
    force the community string at each call.

    Here is the command line I used for tests:

    $snmpget -v 1 -c public localhost sysUpTime.0

    Here is the modified main():

    int
    main(int argc, char *argv[]) {
    while(1) {
    strcpy(argv[4],"public");
    _main(argc, argv);
    }
    }

    Andrea

     
  • Mike Slifcak

    Mike Slifcak - 2004-10-21

    Logged In: YES
    user_id=88697

    Please indicate compiler make/version, os make/version,
    processor type

     
  • Gizero

    Gizero - 2004-10-21

    Logged In: YES
    user_id=1142754

    My test was on a RedHat 9.0 x86 box. I used GNU/gcc 3.2.2
    for the build.

     
  • Wes Hardaker

    Wes Hardaker - 2004-10-29

    Logged In: YES
    user_id=76242

    If you are on a linux box (you are), then try and get "valgrind" (there are
    RPMs for it). Run snmpget as your normally would, but put "valgrind
    --num-callers=16 --leak-check=yes" in front of the command line. That
    should show you where the leaks are in the code.

     
  • Wes Hardaker

    Wes Hardaker - 2004-10-29

    Logged In: YES
    user_id=76242

    If you are on a linux box (you are), then try and get "valgrind" (there are
    RPMs for it). Run snmpget as your normally would, but put "valgrind
    --num-callers=16 --leak-check=yes" in front of the command line. That
    should show you where the leaks are in the code.

     

Log in to post a comment.