[erlang-bugs] bug in filelib:ensure_dir on Windows.

Lukas Larsson <>
Wed May 23 10:11:43 CEST 2012


Hi!

Thanks for reporting this! The following patch[1] should solve the 
problem. I'll let it run through our tests and then merge it to maint.

Thanks,
Lukas

[1] diff --git a/lib/stdlib/src/filelib.erl b/lib/stdlib/src/filelib.erl
index d532cea..b098d4c 100644
--- a/lib/stdlib/src/filelib.erl
+++ b/lib/stdlib/src/filelib.erl
@@ -264,6 +264,9 @@ ensure_dir(F) ->
      case do_is_dir(Dir, file) of
         true ->
             ok;
+       false when Dir =:= F ->
+           %% Protect against infinite loop
+           {error,einval};
         false ->
             ensure_dir(Dir),
             case file:make_dir(Dir) of


On 23/05/12 06:07,  wrote:
>
> Hi.
>
> I run R14B02 on Windows 2K8 64-bit server (but Erlang is 32-bit).  But 
> looking at the latest code from GitHub, the problem is still there.
>
> When I try filelib:ensure_dir("Y:/toto.txt") and the drive "Y:" does 
> not exist, the VM crashes after a few minutes with eheap_alloc cannot 
> allocate 1425410620 bytes of memory (of type "heap").
>
> Looking at the Erlang source code for ensure_dir/1, and if I'm reading 
> it right,  the endless loop is caused because the dirname in 
> "Y:/toto.txt" is "Y:/" but "Y:/" is not considered a directory by 
> do_is_dir/2. So a recursive call to ensure_dir/1 is done, and.....
>
> Is it really a bug?
>
> Luc
>
> ---
>
> //Le cri du nourrisson est le résultat de plusieurs années de 
> recherche dans le domaine du signal d'alarme.//
>
> //(Serge Bouchard)//
>
> ---
>
> Luc Tanguay, ing./P.Eng.
> Bell Canada
> 671 De La Gauchetière 4e étage,
>
> Montréal H3B 2M8
> 514-786-6440
>
> cell: 514-229-7585
>
>
>
> _______________________________________________
> erlang-bugs mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-bugs
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20120523/9eefebc0/attachment.html>


More information about the erlang-bugs mailing list