[erlang-patches] cover: fix file descriptor leak
Henrik Nord
henrik@REDACTED
Mon May 2 14:54:11 CEST 2011
On 04/29/2011 08:07 AM, shunichi shinohara wrote:
> The patch below fixes file descriptor leak of cover module.
>
> git fetch https://github.com/shino/otp.git shino/fix-cover-fd-leak
>
> Explanation:
>
> Data import of cover module is called with a file path and
> open a fd internally. The fd should be closed in cover module,
> but it does not.
> As an additional information, in data export it closes a fd properly.
>
> This patch does not include test code because
> - I can't find the way to execute test suites, and
> - I don't know how to find fd list in beam process.
>
> Steps to reproduce:
>
> I tested the patch on Mac OS X 10.6.7, 64bit.
>
> 1. Run the escript below, and find the process id (OS pid).
> ============
> #!/usr/bin/env escript
> -export([main/1]).
>
> main([]) ->
> file:write_file("sample.erl",<<"-module(sample).\n">>),
> {ok, sample} = cover:compile("sample.erl"),
> ok = cover:export("sample.coverdata", sample),
> ok = cover:import("sample.coverdata"),
> io:format("~s~n", [os:cmd("lsof -p " ++ os:getpid())]).
> ============
>
> 2. Confirm cover's data file is NOT listed in output.
>
> Before apply this patch, script outputs the line like:
> beam.smp 17008 shino 11r REG 14,5 89 567192 /path/to/sample.coverdata
>
> After this patch is applied, lsof does not report "sample.coverdata".
>
> Regards,
> Shunichi Shinohara (shino.shun@REDACTED)
> _______________________________________________
> erlang-patches mailing list
> erlang-patches@REDACTED
> http://erlang.org/mailman/listinfo/erlang-patches
Hi
I have now included this branch in 'pu' and I will let it cook for a while.
Information on how to invoke the tests can be found on the github wiki:
https://github.com/erlang/otp/wiki/Running-tests
If you have additional questions do not hesitate to ask
Thank you for the contribution!
--
/Henrik Nord Erlang/OTP
More information about the erlang-patches
mailing list