[erlang-bugs] HiPe compiler FP inlining crashing

Mattias Jansson mattias.jansson@REDACTED
Wed Nov 25 14:25:20 CET 2015


Hello.

I am having a problem with a crashing HiPe compiler.

It has been tested on Erlang OTP 18.1 (64-bit) on OSX 10.11.1, and also on Fedora Linux 22 with OTP versions 18.0 and 17.5 (64-bit).
It crashes on Linux as well as OSX, but it does not crash in OTP 17.5. This has only been seen in 18.*

The following code has been shrunk to remain syntactically correct and still show the error when compiling
(you’d be surprised by how much of this code is actually necessary to reproduce this).

<code>
-module(rat_calc).

-export([eat/0]).

eat() ->
    eat_what(1.0, #{}).

eat_what(Factor, #{rat_type := LT} = Rat) ->
    #{ cheese := Cheese } = Rat,
    UnitCheese = Cheese / 2,
    RetA = case eat() of
               {full, RetA1} ->
                   CheeseB2 = min(RetA1, UnitCheese) * Factor,
                   case eat() of
                       full ->
                           {win, RetA1};
                       hungry ->
                           {partial, RetA1 - CheeseB2}
                   end;
               AOther ->
                   AOther
           end,
    RetB = case eat() of
               {full, RetB1} ->
                   CheeseA2 = min(RetB1, UnitCheese) * Factor,
                   rat:init(single, LT, CheeseA2),
                   case eat() of
                       full ->
                           {full, RetB1};
                       hungry ->
                           {hungry, RetB1 - CheeseA2}
                   end
           end,
    {RetA, RetB}.
</code>

The code compiles without problem if running the compiler without the +native flag. With the flag, the compiler will crash.
If compiling with the no_inline_fp flag enabled, the compiler does not crash.

Thanks.
// Mattias Jansson


More information about the erlang-bugs mailing list