[erlang-bugs] +A option causes segmentation fault on Linux
Mikage Sawatari
mikage@REDACTED
Fri Jun 1 10:25:27 CEST 2007
Hello,
The code at the end of message crashes on Linux with segmentation
fault when the option +A is specified. Without the option it
works. It creates a lot of files simultaneously, and calls
file:sync().
> time erl +A 2 -noshell -s testasync test -s init stop
Segmentation fault
real 0m1.149s
user 0m0.308s
sys 0m0.795s
> time erl -noshell -s testasync test -s init stop
real 0m24.470s
user 0m2.137s
sys 0m4.981s
We have tested on the following environments:
SuSE Linux 9.2 (i586) (kernel 2.6.8-24-bigsmp)
Erlang (ASYNC_THREADS,HIPE) (BEAM) emulator version 5.5.4
SUSE LINUX Enterprise Server 9 (x86_64) (kernel 2.6.5-7.201-smp)
Erlang (ASYNC_THREADS,HIPE) (BEAM) emulator version 5.5.4
---- CUT HERE ----
-module(testasync).
-compile(export_all).
% Specify a directory at which we can store many files.
-define(DIR, "/home/rd/erlang/tmp").
-define(NUM, 100).
-define(CONCURRENT, 100).
test() ->
run(?CONCURRENT).
run(0) ->
ok;
run(N) ->
spawn(?MODULE, run, [N, ?NUM]),
run(N-1).
run(_N, 0) ->
ok;
run(N, I) ->
makefile(N, I),
run(N, I-1).
makefile(N, I) ->
Data = term_to_binary({N, I}, [compressed]),
Filename = hex(term_to_binary(now())),
% io:format("~p~n", [Filename]),
FilePath = ?DIR ++ "/" ++ Filename,
{ok, Fd} = file:open(FilePath, [write, raw, binary]),
Size = size(Data),
SizeBin = <<Size:32>>,
file:write(Fd, SizeBin),
file:write(Fd, Data),
file:sync(Fd),
file:close(Fd).
hex(B) when binary(B) ->
hex(binary_to_list(B));
hex(L) when list(L) ->
lists:flatten([hex(I) || I <- L]);
hex(I) when I > 16#f ->
[hex0((I band 16#f0) bsr 4), hex0((I band 16#0f))];
hex(I) -> [$0, hex0(I)].
hex0(10) -> $a;
hex0(11) -> $b;
hex0(12) -> $c;
hex0(13) -> $d;
hex0(14) -> $e;
hex0(15) -> $f;
hex0(I) -> $0 +I.
---- CUT HERE ----
----
SAWATARI Mikage
More information about the erlang-bugs
mailing list