Uploaded image for project: 'Erlang/OTP'
  1. Erlang/OTP
  2. ERL-1427

Binary comprehensions crash the compiler when a generated variable is used as a generator

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 21.3, 23.1.1
    • Fix Version/s: 23.2
    • Component/s: compiler
    • Labels:

      Description

      (actually tested on 23.1.2, not 23.1.1)

       

      The following module:

      -module(x).
      -compile(export_all).
      
      f() -> << <<X>> || L <- [[1]], X <- L >>.
      

      causes OTP 23.1.2 to crash with the following error:

      1> c("x").                           
      Function: f/0
      x.erl: internal error in beam_kernel_to_ssa;
      crash reason: {case_clause,
          {'EXIT',
              {{badkey,'L'},
               [{erlang,map_get,['L',#{'@ssa_ret' => {b_var,'@ssa_ret'}}],[]},
                {beam_kernel_to_ssa,ssa_arg,2,
                    [{file,"beam_kernel_to_ssa.erl"},{line,1224}]},
                {beam_kernel_to_ssa,bif_cg,5,
                    [{file,"beam_kernel_to_ssa.erl"},{line,1222}]},
                {beam_kernel_to_ssa,cg,2,
                    [{file,"beam_kernel_to_ssa.erl"},{line,111}]},
                {beam_kernel_to_ssa,do_match_cg,3,
                    [{file,"beam_kernel_to_ssa.erl"},{line,154}]},
                {beam_kernel_to_ssa,cg_fun,2,
                    [{file,"beam_kernel_to_ssa.erl"},{line,89}]},
                {beam_kernel_to_ssa,function,2,
                    [{file,"beam_kernel_to_ssa.erl"},{line,73}]},
                {beam_kernel_to_ssa,'-functions/2-lc$^0/1-0-',2,
                    [{file,"beam_kernel_to_ssa.erl"},{line,63}]}]}}}
      
        in function  compile:'-select_passes/2-anonymous-2-'/3 (compile.erl, line 684)
        in call from compile:'-internal_comp/5-anonymous-0-'/3 (compile.erl, line 404)
        in call from compile:fold_comp/4 (compile.erl, line 431)
        in call from compile:internal_comp/5 (compile.erl, line 415)
        in call from compile:'-do_compile/2-anonymous-0-'/2 (compile.erl, line 207)
        in call from compile:'-do_compile/2-anonymous-1-'/1 (compile.erl, line 223)
      x.erl:3: Warning: export_all flag enabled - all functions will be exported
      error
      

      and OTP 21.3 with

      1> c("x").
      Function: f/0
      x.erl: internal error in sys_core_dsetel;
      crash reason: {case_clause,
          {'EXIT',
              {{case_clause,#{}},
               [{sys_core_dsetel,visit,2,[{file,"sys_core_dsetel.erl"},{line,98}]},
                {lists,mapfoldl,3,[{file,"lists.erl"},{line,1354}]},
                {sys_core_dsetel,visit,2,[{file,"sys_core_dsetel.erl"},{line,188}]},
                {sys_core_dsetel,visit,2,[{file,"sys_core_dsetel.erl"},{line,129}]},
                {sys_core_dsetel,visit,2,[{file,"sys_core_dsetel.erl"},{line,126}]},
                {sys_core_dsetel,visit_module_1,3,
                    [{file,"sys_core_dsetel.erl"},{line,80}]},
                {sys_core_dsetel,visit_module,1,
                    [{file,"sys_core_dsetel.erl"},{line,76}]},
                {sys_core_dsetel,module,2,
                    [{file,"sys_core_dsetel.erl"},{line,71}]}]}}}
      
        in function  compile:'-select_passes/2-anonymous-2-'/3 (compile.erl, line 585)
        in call from compile:'-internal_comp/5-anonymous-1-'/3 (compile.erl, line 349)
        in call from compile:fold_comp/4 (compile.erl, line 376)
        in call from compile:internal_comp/5 (compile.erl, line 360)
        in call from compile:'-do_compile/2-anonymous-0-'/2 (compile.erl, line 177)
        in call from compile:'-do_compile/2-anonymous-1-'/1 (compile.erl, line 190)
      x.erl:3: Warning: export_all flag enabled - all functions will be exported
      error
      

      However, in both versions of REPL the expression does not cause any problems:

      2> << <<X>> || L <- [[1]], X <- L >>.
      <<1>>
      

        Attachments

          Activity

            People

            Assignee:
            bjorn Björn Gustavsson
            Reporter:
            radrow Radoslaw Rowicki
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: