Core dump using HiPE (possibly my fault ;-))

Mikael Pettersson mikpe@REDACTED
Tue Feb 11 14:02:03 CET 2003


Thierry Mallard writes:
 > Greetings,
 > 
 > Vlad Dumitrescu helped me optimize a quick bench about computing some
 > numbers. You'll find the corresponding source attached to this mail.
 > 
 > I got a core dump when trying to run this test using HiPE :
 > 
 > -=-=-=-
 > [shaman@REDACTED test1]$ erl
 > Erlang (BEAM) emulator version 5.2 [source] [hipe]
 > 
 > Eshell V5.2  (abort with ^G)
 > 1> c(test1, [native, {hipe, [o3]}]).
 > {ok,test1}
 > 2> test1:run(10000, 10000).
 > Generating list of 10000 floats ... <0.36.0>
 > done
 > original Test time : 107.411 seconds 
 > 3> no next heap size found: 197920092, offset 0
 >                                                Aborted (core dumped)

I've been trying to fix this bug, believing that it was HiPE's fault.
However, the module below which is derived from Thierry's test1 module reliably
crashes OTP R9B built --without-hipe, on both SPARC and x86. Apparently, BEAM
has a generic space leak bug which will only trigger in specific cases, and
this is what hit the HiPE-compiled code Thierry tried to run.

I've reported this to the appropriate runtime hacker @ OTP.

/Mikael

%%% bug.erl
%%% Usage:
%%%	erl
%%%	1> c(bug).
%%%	2> bug:test().
%%% Result:
%%%	no next heap size found: 146757041, offset 0
%%%	                                            Abort
%%% Furthermore, the process that caused the crash is described
%%% in erl_crash.dump as having an insanely (approx 145 megawords)
%%% large amount of message buffer data.

-module(bug).
-export([test/0]).
-export([run/2, run1/3]).

test() ->
    run(10000, 10000).

run(ListSize, LoopCount) ->
    Pid = spawn_opt(?MODULE, run1, [ListSize, LoopCount, self()], [{min_heap_size, 1000000},{fullsweep_after, 0}]),
    receive
	Pid -> ok
    end.

run1(ListSize, LoopCount, Pid) ->
    List = lists:duplicate(ListSize, ok),
    erlang:garbage_collect(),
    loop(LoopCount, List),
    Pid ! self().

loop(0, _) ->
    ok;
loop(LoopCount, List) ->
    loop(LoopCount-1, change_list(List)).

change_list(L) ->
    change_list(L, []).
change_list([], Accum) ->
    lists:reverse(Accum);
change_list([X|List], Accum) ->
    change_list(List, [change_it(X) | Accum]).

%%% Note that the result from change_it/1 is of bounded size:
%%% atom -> {atom} -> [atom] -> atom -> ...
change_it({X}) -> [X];
change_it([X]) -> X;
change_it(X) when atom(X) -> {X}.



More information about the erlang-questions mailing list