file:position hangs when seeking off the end of a gzipped file

Matthias Lang matthias@REDACTED
Wed May 17 19:43:04 CEST 2006


Hi,

This program hangs. I didn't expect it to.

One workaround is to use file:read() to do the seeking.

Matthias

%%----------------------------------------------------------------------
%% Test case which demonstrates an infinite hang when seeking off the end
%% of gzip-compressed files. Hangs on R10B-10 and R11B-0 compiled from
%% source on debian linux.
%% 
-module(gzip_hang).
-export([go/0]).

filename() ->
    "/tmp/crash.gz".

go() ->
    %% Create a valid gzip file
    {ok, F} = file:open(filename(), [write, compressed]),
    ok = file:write(F, "five boxing wizards jump quickly"),
    ok = file:close(F),

    %% Open it again
    {ok, G} = file:open(filename(), [read, compressed]),
    file:position(G, 123).




More information about the erlang-questions mailing list