[erlang-bugs] beam_validator does not validate against circularity in constructed values

Erik Søe Sørensen <>
Mon Jun 27 11:15:28 CEST 2011


The following function passes beam_validator verification, but calls a 
gc_bif while a tuple is not completely constructed.
(I take it that that could wreak havoc in the interpreter and is thus 
illegal and technically a validator bug; I'm not completely certain of 
this though. Apologies if this is not a bug after all.)

    {module, beamtoying5}.  %% version = 0
    {exports, [{gc_in_cons,1},{gc_in_cons2,1}]}.
    {attributes, []}.
    {labels, 4}.

    {function, gc_in_cons, 1, 2}.
      {label,1}.
        {func_info,{atom,beamtoying5},{atom,gc_in_cons},1}.
      {label,2}.
        {test_heap,3,1}.
        {put_tuple,2,{x,1}}.
        {put,{atom,dummy}}.
        {gc_bif,'bnot',{f,0},1,[{x,0}],{x,0}}.
        {put,{x,0}}.
        {move,{x,1},{x,0}}.
        return.

Another thing: If the "put dummy" instruction is moved down beside the 
"put x0" instruction, then we get a function which also passes 
beam_validator validation, yet results in the following error message 
when the module is loaded:

    =ERROR REPORT==== 27-Jun-2011::11:14:10 ===
    Loading of /home/erik/kode/q/beamtoying5.beam failed: badfile
    {error,badfile}

    =ERROR REPORT==== 27-Jun-2011::11:14:10 ===
    beam/beam_load.c(1771): Error loading function
    beamtoying5:gc_in_cons2/1: op put_tuple u x:
      no specific operation found

because the instruction rewriter expects a "put" directly after a 
"put_tuple".


Regards,
Erik Søe Sørensen



More information about the erlang-bugs mailing list