Technical article 110871

foosmuxd example code in SCO OpenServer 5.0.4 has a memory leak.

OpenServer 5.0.4OpenServer 5.0.5

Written · Last revised

Problem

An example SNMP SMUX daemon is provided in OpenServer 5.0.4 in the directory "/usr/src/cmd/net/smux-samp". If the example, "foosmuxd" is compiled and run on the system and the "getmany(ADMN)" command is used to interrogate the example MIB, after several iterations, the "ps(C)" utility shows the size of the process increasing, in 4KB amounts.

For example, start the daemon as the system "root" user:

# ./foosmuxd
Check that it is running:
    # ps -ef |grep foosmuxd
root 25266 24890  7 09:30:47   ttyp0    00:00:00 grep foosmuxd
root 25264     1  0 09:30:31       ?    00:00:00 ./foosmuxd

Monitor the "ps" "SZ" variable by running:

# while true
> do
> ps -ef |grep foo
> done
or similar:
# while [ 1 ] ; do sleep 1 ; ps -ef -ovsz -osize -ocomm |
grep foosmuxd ; done
Run the getmany command:
# getmany localhost public 1.3.6.1.4.1.9999.1.4.1.2

The ps command should show the "SZ" field increase:

...
20 S 0  4963 19369 32  73 24 fb122ed0  152 fb122ed0 ttyp0
00:00:00 foosmuxd
                                        ^
                                        +--- Here

Solution

This has been fixed in the example code in SCO OpenServer 5.0.5.

The following code may be added to the Release 5.0.4 example "foosmuxd.c" program code at the end of the "doit_smux()" function so it appears as follows:

...
...
    default:
        LIB_ERROR1("badOperation: %d", event->offset);
        (void) smux_close(protocolError);
        goto losing;
    }
    free_SNMP_SMUX_PDU(event);          <------ New call
}

See also

smux_util(SLIB), getmany(ADMN), oid(SLIB)

From the Xinuos technical article database, record 110871. Reproduced with permission. The original is at www.sco.com/ta/110871, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.