Erlang Mailing Lists

Author Message

<  Erlang bugs mailing list  ~  R13B02: hipe:load/1 crashes when called with a sticky module

Guest
Posted: Wed Nov 04, 2009 10:09 am Reply with quote
Guest
Hello,

The source code of hipe:load/1 shows that it's supposed to work with
sticky modules, but in fact, it's not.

load(Mod, BeamFileName) when is_list(BeamFileName) ->
Architecture = erlang:system_info(hipe_architecture),
ChunkName = hipe_unified_loader:chunk_name(Architecture),
case beam_lib:chunks(BeamFileName, [ChunkName]) of
{ok,{_,[{_,Bin}]}} when is_binary(Bin) -> do_load(Mod, Bin, Bin);
% <-- here, Bin is the native chunk
Error -> {error, Error}
end.

then do_load goes like this :
do_load(Mod, Bin, WholeModule) ->
...
case WholeModule of
...
BinCode when is_binary(BinCode) ->
case code:is_sticky(Mod) of
true ->
% this is where we end up for sticky modules such as lists (hipe.erl,
line 917)

%% We unpack and repack the Beam binary as a workaround to
%% ensure that it is not compressed.
{ok, _, Chunks} = beam_lib:all_chunks(WholeModule), % <--
WholeModule is still the native chunk above (line 928).
{ok, Beam} = beam_lib:build_module(Chunks),
%% Don't purge or register sticky mods; just load native.
code:load_native_sticky(Mod, Bin, Beam);
...
end
end.

The crash happens line 928 :
** exception error: no match of right hand side value {error,beam_lib,

{not_a_beam_file,<<131,108,0,0,0,11,104,2,107,0,5,51,46,
55,46,51,98,2,132,8,38,97,8,97
,...>>}}
in function hipe:do_load/3

Indeed, it's not a beam file, it's a beam native chunk.

Paul
--
Semiocast http://titema.com/
+33.175000290 - 62 bis rue Gay-Lussac, 75005 Paris


________________________________________________________________
erlang-bugs mailing list. See http://www.erlang.org/faq.html
erlang-bugs (at) erlang.org

Post received from mailinglist

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum