0

代码如下:

-module(hipe_crash). 
-export([f/6]). 

f(A, B, C, D, E, L) -> 
    lists:foldl(fun (X, P) -> 
        AVar = case A of 
            0 -> 1 / D; 
            N -> N / (C - B) 
        end, 
        BVar = case E of 
            atom1 -> 1.0; 
            atom2 -> 0.8; 
            _ -> E 
        end, 
        CVar = case X of 
            atom1 -> 0.1 * AVar; 
            _ -> 1.0 
        end, 
        P * BVar * CVar 
    end, 1, L). 

编译这段代码erlc没有报错,编译正常。但是当我用 编译它时erlc +native,编译器崩溃了,信息如下:

<HiPE (v 3.9.2)> EXITED with reason {function_clause,[{hipe_icode_fp,assert_assigned,[[{30,{icode_variable,40,fvar,[]}}]],[{file,[104,105,112,101,95,105,99,111,100,101,95,102,112,46,101,114,108]},{line,772}]},{hipe_icode_fp,bindings_are_assigned,1,[{file,[104,105,112,101,95,105,99,111,100,101,95,102,112,46,101,114,108]},{line,766}]},{hipe_icode_fp,filter_map,3,[{file,[104,105,112,101,95,105,99,111,100,101,95,102,112,46,101,114,108]},{line,753}]},{hipe_icode_fp,transform_block,2,[{file,[104,105,112,101,95,105,99,111,100,101,95,102,112,46,101,114,108]},{line,162}]},{hipe_icode_fp,cfg,1,[{file,[104,105,112,101,95,105,99,111,100,101,95,102,112,46,101,114,108]},{line,48}]},{hipe_main,icode_ssa_type,4,[{file,[104,105,112,101,95,109,97,105,110,46,101,114,108]},{line,273}]},{hipe_main,icode_ssa,4,[{file,[104,105,112,101,95,109,97,105,110,46,101,114,108]},{line,255}]},{hipe_main,compile_icode,5,[{file,[104,105,112,101,95,109,97,105,110,46,101,114,108]},{line,109}]}]} @hipe:829
hipe_crash.erl:none: internal error in native_compile;
crash reason: {{hipe,829,
                   {function_clause,
                       [{hipe_icode_fp,assert_assigned,
                            [[{30,{icode_variable,40,fvar,[]}}]],
                            [{file,"hipe_icode_fp.erl"},{line,772}]},
                        {hipe_icode_fp,bindings_are_assigned,1,
                            [{file,"hipe_icode_fp.erl"},{line,766}]},
                        {hipe_icode_fp,filter_map,3,
                            [{file,"hipe_icode_fp.erl"},{line,753}]},
                        {hipe_icode_fp,transform_block,2,
                            [{file,"hipe_icode_fp.erl"},{line,162}]},
                        {hipe_icode_fp,cfg,1,
                            [{file,"hipe_icode_fp.erl"},{line,48}]},
                        {hipe_main,icode_ssa_type,4,
                            [{file,"hipe_main.erl"},{line,273}]},
                        {hipe_main,icode_ssa,4,
                            [{file,"hipe_main.erl"},{line,255}]},
                        {hipe_main,compile_icode,5,
                            [{file,"hipe_main.erl"},{line,109}]}]}},
               [{hipe,finalize_fun_sequential,3,
                    [{file,"hipe.erl"},{line,829}]},
                {hipe,'-finalize_fun_concurrent/3-fun-3-',4,
                    [{file,"hipe.erl"},{line,795}]}]}

我在: http ://erlang.2086793.n4.nabble.com/internal-error-in-native-compile-td2298937.html中找到了这段代码。但我无法获得有关此代码为何会使编译器崩溃的更多信息。

4

1 回答 1

0

BEAM 浮点运算的优化之一是将浮点运算分组到块中,如果某些中间运算失败,BEAM 将发出 badarith 信号。它依赖于头饰。
我认为这是异常处理程序的错误。您可以no_inline_fp以禁用所有浮点优化为代价来使用 HiPE 编译器选项。

于 2013-08-15T05:56:39.457 回答