[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}.

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 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 

Erik Søe Sørensen

More information about the erlang-bugs mailing list