[Mono-dev] file handle leak in cpu_load
Alexander Köplinger
alex.koeplinger at outlook.com
Tue Dec 2 13:16:35 UTC 2014
I opened a PR on your behalf: https://github.com/mono/mono/pull/1434
-- Alex
> Date: Tue, 2 Dec 2014 13:02:54 +0100
> From: markus.beth at zkrd.de
> To: alex.koeplinger at outlook.com
> CC: mono-devel-list at lists.ximian.com
> Subject: Re: [Mono-dev] file handle leak in cpu_load
>
> Not easily, as I do not have an account on GitHub.
>
> Am Tue, 2 Dec 2014 12:12:04 +0100
> schrieb Alexander Köplinger <alex.koeplinger at outlook.com>:
>
> > Can you send a pull request on GitHub?
> >
> > > Date: Tue, 2 Dec 2014 12:01:29 +0100
> > > From: markus.beth at zkrd.de
> > > To: mono-devel-list at lists.ximian.com
> > > Subject: [Mono-dev] file handle leak in cpu_load
> > >
> > > Hi all,
> > >
> > > last week we used the profiler of a mono 3.10.0 installation on
> > > Linux x86_64 and we found it leaks file handles (for /proc/loadavg).
> > >
> > > I located the problem in the function cpu_load in
> > > mono/utils/mono-counters.c. If a premature return is taken, the
> > > FILE pointer f is not fclose()-ed.
> > >
> > > I propose the following fix:
> > >
> > > ---
> > > mono/utils/mono-counters.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/mono/utils/mono-counters.c b/mono/utils/mono-counters.c
> > > index 1e0840c..c669454 100644
> > > --- a/mono/utils/mono-counters.c
> > > +++ b/mono/utils/mono-counters.c
> > > @@ -360,6 +360,7 @@ cpu_load (int kind)
> > > FILE *f = fopen ("/proc/loadavg", "r");
> > > if (f) {
> > > len = fread (buffer, 1, sizeof (buffer) - 1, f);
> > > + fclose (f);
> > > if (len > 0) {
> > > buffer [len < 511 ? len : 511] = 0;
> > > b = buffer;
> > > @@ -374,7 +375,6 @@ cpu_load (int kind)
> > > }
> > > }
> > > }
> > > - fclose (f);
> > > }
> > > #endif
> > > return 0;
> > > --
> > >
> > > It applies on master and also (with an offset of -32 lines) on
> > > mono-3.10.0-branch.
> > >
> > > What do you think?
> > >
> > > Regards,
> > > Markus
> > > _______________________________________________
> > > Mono-devel-list mailing list
> > > Mono-devel-list at lists.ximian.com
> > > http://lists.ximian.com/mailman/listinfo/mono-devel-list
> >
>
>
> --
> Markus Beth ZKRD
> Software Developer Zentrales Knochenmarkspender-Register
> Fon: +49 731 1507-421 fuer die Bundesrepublik Deutschland
> Fax: +49 731 1507-502 Gemeinnuetzige Gesellschaft mbH
> http://www.zkrd.de/ Helmholtzstraße 10, 89081 Ulm, Germany
> ---------------------------------------------------------------------
> Registergericht: Amtsgericht Ulm, HRB 2566, UID-Nr.: DE269639005
> Geschäftsführer: Dr. Peter Mein und Dr. Dr. Carlheinz Müller
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20141202/8fdeade0/attachment.html>
More information about the Mono-devel-list
mailing list