HiPE bug with nested try/catch

Trap Exit trapexit.erlang-bugs@REDACTED
Fri Jul 21 10:09:03 CEST 2006


According to the Erlang ref. manual: 
Quote:
If an exception occurs during evaluation of Expr but there is no matching ExceptionPattern of the right Class with a true guard sequence, the exception is passed on as if Expr had not been enclosed in a try expression.
(end of quote)


So I constructed the following example and noticed that it behaved differently when HiPE compiled.


-module(trycatch).

-export([main/0]).

main() ->
    try
        f()
    catch
        throw:Throw ->
            io:format("gotcha: ~p~n", [Throw])
    end.

f() ->
    try
        throw('i.wonder.who.will.catch.me')
    catch
        error:Error ->
            io:format("function f caused an error: ~p~n", [Error])
    end.



Erlang (BEAM) emulator version 5.5 [source] [async-threads:0] [hipe]

Eshell V5.5  (abort with ^G)
1> c(trycatch).
{ok,trycatch}
2> trycatch:main().
gotcha: 'i.wonder.who.will.catch.me'
ok
3> c(trycatch,native).
{ok,trycatch}
4> trycatch:main().

=ERROR REPORT==== 21-Jul-2006::09:56:33 ===
Error in process <0.32.0> with exit value: {undef,[{erlang,raise,[[[{erlang,raise,[[true|16#4044646A0000000000000000000000000000006A],'i.wonder.who.will.catch.me']},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]|-16#0000000000000000000000000010],undef]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}

** exited: {undef,[{erlang,raise,
                           [[[{erlang,raise,
                                      [[true|
                                        366900607304749881568687426529269484530033492074],
                                       'i.wonder.who.will.catch.me']},
                              {erl_eval,do_apply,5},
                              {shell,exprs,6},
                              {shell,eval_loop,3}]|
                             -00000000000000000016],
                            undef]},
                   {erl_eval,do_apply,5},
                   {shell,exprs,6},
                   {shell,eval_loop,3}]} **

_________________________________________________________
Post sent from http://www.trapexit.org



More information about the erlang-bugs mailing list