[torqueusers] Possible oversite in torque_gssapi

Ken Nielson knielson at adaptivecomputing.com
Wed Nov 25 09:16:03 MST 2009


Mike Coyne wrote:
>
> In building the gassapi version ot torque from the svn archive I ran 
> across a memory leak in pbs_mom after running valgrind
>
> It would appear the buffers allocated int the DIS_tcp_setup() didn’t 
> get seem to be free’d when the
>
> DIS_tcp_release() was called so I proposed adding the following…
>
> This may have resulted from a bad job incorporating the latest update 
> in svn to my local build but I though I would ask the group if this is 
> the right place to free the buffers?
>
> Index: /trunk/torque_gss/src/lib/Libifl/tcp_dis.c
>
> ===================================================================
>
> --- /trunk/torque_gss/src/lib/Libifl/tcp_dis.c (revision 534)
>
> +++ /trunk/torque_gss/src/lib/Libifl/tcp_dis.c (revision 538)
>
> @@ -1075,16 +1075,28 @@
>
> #ifdef GSSAPI
>
> OM_uint32 minor;
>
> #endif
>
> + struct tcp_chan *tcp;
>
> + struct tcpdisbuf *tp;
>
> +
>
> assert (fd >= 0);
>
> if (fd >= tcparraymax || tcparray[fd] == NULL)
>
> return; /* Might be an RPP connection */
>
> +
>
> + tcp=tcparray[fd];
>
> + tp = &tcp->readbuf;
>
> + if (tp->tdis_thebuf != NULL) free(tp->tdis_thebuf);
>
> + tp = &tcp->writebuf;
>
> + if (tp->tdis_thebuf != NULL) free(tp->tdis_thebuf);
>
> #ifdef GSSAPI
>
> if (tcparray[fd]->gssctx != GSS_C_NO_CONTEXT)
>
> gss_delete_sec_context (&minor, &tcparray[fd]->gssctx, GSS_C_NO_BUFFER);
>
> if (tcparray[fd]->unwrapped.value)
>
> gss_release_buffer (&minor, &tcparray[fd]->unwrapped);
>
> + /*fix memory loss in DIS_scp_setup */
>
> + tp = &tcp->gssrdbuf;
>
> + if (tp->tdis_thebuf != NULL) free(tp->tdis_thebuf);
>
> #endif
>
> free(tcparray[fd]);
>
> tcparray[fd] = NULL;
>
> ------------------------------------------------------------------------

Mike,

If you look at the DIS_tcp_setup() code you will see that it is trying 
to reuse slots are no longer in use and avoid the need to allocate new 
memory every time. Valgrind will show this as a leak but in reality it 
is TORQUE's way of caching resources. By calling free on readbuf, 
writebuf and gssrdbuf it looks like you will cause a seg fault the next 
time DIS_tcp_setup is called using the same socket descriptor value.

Ken Nielson
Adaptive Computing


More information about the torqueusers mailing list