R13B02: hipe:load/1 crashes when called with a sticky module

Paul Guyot pguyot@REDACTED
Wed Nov 4 11:09:29 CET 2009


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



More information about the erlang-bugs mailing list