[erlang-questions] file:position/2 hangs up whole enode

Alex Morarash <>
Mon Jan 31 10:23:23 CET 2011


Thanks! I applied this patch. Works fine.
IMHO, need to post this to upstream.


On 29 January 2011 18:27, Michael Santos <> wrote:
> On Thu, Jan 27, 2011 at 05:02:37PM +0200, Alex Morarash wrote:
>> Hi all!
>>
>> Just another way to completely hang up a whole erlang node:
>> open compressed file for read and move file position after
>> actual size of uncompressed data.
>>
>> Stable reproduce in at least from R12B5 till R14B1.
>>
>> Here is the example.
>>
>>
> The gzio driver is spinning on the end of the file. This patch just
> checks if the file offset changes after reading from the stream:
>
> $ touch test.gz
> $ bin/erl
> 1> {ok,H} = file:open("test.gz", [read,compressed]).
> {ok,<0.34.0>}
> 2> file:position(H,10).
> {ok,0}
>
>
> diff --git a/erts/emulator/drivers/common/gzio.c b/erts/emulator/drivers/common/gzio.c
> index 5531a27..2b33f74 100644
> --- a/erts/emulator/drivers/common/gzio.c
> +++ b/erts/emulator/drivers/common/gzio.c
> @@ -633,4 +633,5 @@ erts_gzseek(gzFile file, int offset, int whence)
>        char buf[512];
>        int n;
> +       int cur = s->position;
>
>        n = pos - s->position;
> @@ -644,4 +645,5 @@ erts_gzseek(gzFile file, int offset, int whence)
>            erts_gzwrite(file, buf, n);
>        }
> +       if (cur == s->position) break;
>     }
>
>
>


More information about the erlang-questions mailing list