Quantcast

HiPe compiler FP inlining crashing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

HiPe compiler FP inlining crashing

Mattias Jansson
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
_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HiPe compiler FP inlining crashing

Mikael Pettersson-5
Mattias Jansson writes:
 > Hello.
 >
 > I am having a problem with a crashing HiPe compiler.

Note, it's "HiPE" not "HiPe".

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

I can reproduce the compiler crash with OTP 18.1 on Linux/x86_64, but not with OTP 17.5.
The crash is in a sanity check (hipe_icode_fp:assert_assigned/1) at the ICode level, well
before any target-dependent code is generated.

This could be caused by changes in the BEAM compiler's output, or by some change in HiPE.
Presumably a git bisect ought to identify it; care to try that?

/Mikael
_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HiPe compiler FP inlining crashing

Kostis Sagonas-2
On 11/25/2015 08:46 PM, Mikael Pettersson wrote:
>   > 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.
>
> I can reproduce the compiler crash with OTP 18.1 on Linux/x86_64, but not with OTP 17.5.
> The crash is in a sanity check (hipe_icode_fp:assert_assigned/1) at the ICode level, well
> before any target-dependent code is generated.
>
> This could be caused by changes in the BEAM compiler's output, or by some change in HiPE.
> Presumably a git bisect ought to identify it; care to try that?

I've also looked at this one this afternoon.  I am willing to bet this
is related to the presence of maps in the code -- most likely due to
their "better" compilation by BEAM in 18.x.

Given that the code that propagates floating point values in ICode was
written back in 2003 or so and practically not much changed since then,
it's not surprising that this code breaks as new types and instructions
are introduced to the BEAM compiler.

I'll try to find some time to look into this, but would not mind if
somebody else beats me to it.

Kostis


_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HiPe compiler FP inlining crashing

Björn-Egil Dahlberg-2
snarky ..

Before anyone goes on a wild-goose chase, there exists another sample code, without maps, that also crashes the HiPE compiler on,
- 18.1
- 17.5.6
- OTP_R16B03-1
- OTP_R15B03-1
- stopped testing here .. perhaps the bug is in the original implementation ..

f(A, C, D, E, L) ->
    lists:foldl(fun (X, P) ->
                        AVar = case A of
                                   0 -> 1 / D;
                                   N -> N / C
                               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).

Not necessarily the same bug as above but it has the same symptoms, i.e. function clause on hipe_icode_fp assert_assigned and no_inline_fp compiles fine.



2015-11-25 22:20 GMT+01:00 Kostis Sagonas <[hidden email]>:
On 11/25/2015 08:46 PM, Mikael Pettersson wrote:
  > 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.

I can reproduce the compiler crash with OTP 18.1 on Linux/x86_64, but not with OTP 17.5.
The crash is in a sanity check (hipe_icode_fp:assert_assigned/1) at the ICode level, well
before any target-dependent code is generated.

This could be caused by changes in the BEAM compiler's output, or by some change in HiPE.
Presumably a git bisect ought to identify it; care to try that?

I've also looked at this one this afternoon.  I am willing to bet this is related to the presence of maps in the code -- most likely due to their "better" compilation by BEAM in 18.x.

Given that the code that propagates floating point values in ICode was written back in 2003 or so and practically not much changed since then, it's not surprising that this code breaks as new types and instructions are introduced to the BEAM compiler.

I'll try to find some time to look into this, but would not mind if somebody else beats me to it.

Kostis



_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs


_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: HiPe compiler FP inlining crashing

Kostis Sagonas-2
In reply to this post by Mattias Jansson
On 11/25/2015 02:25 PM, Mattias Jansson wrote:

> 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>
>    SNIP
> </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 for the bug report.  A pull request which fixes this particular
problem has been submitted on github:

   https://github.com/erlang/otp/pull/984

Most likely, it will appear in the next Erlang/OTP release.

Kostis
_______________________________________________
erlang-bugs mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-bugs
Loading...