| Author |
Message |
|
| lindau |
Posted: Fri Jul 21, 2006 8:09 am |
|
|
|
Joined: 20 Jul 2006
Posts: 4
|
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.
So I constructed the following example and noticed that it behaved differently when HiPE compiled.
Code:
-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.
Code:
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}]} **
|
|
|
| Back to top |
|
| Guest |
Posted: Thu Aug 03, 2006 12:05 pm |
|
|
|
Guest
|
On Fri, 21 Jul 2006 09:09:03 +0100, Trap Exit wrote:
(badly encoding-damaged)
>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}]} **
Thanks for reporting this. The bug has been fixed and the fix will
be included in the next OTP-R11B update. In the mean time you can
use the patch below.
/Mikael Pettersson
The HiPE Team
--- otp-0704/lib/compiler/src/beam_disasm.erl.~1~ 2006-06-27 15:58:34.000000000 +0200
+++ otp-0704/lib/compiler/src/beam_disasm.erl 2006-08-03 12:48:02.000000000 +0200
@@ -850,7 +850,8 @@ resolve_inst({try_case,[Reg]},_,_,_) ->
resolve_inst({try_case_end,[Arg]},_,_,_) ->
{try_case_end,resolve_arg(Arg)};
resolve_inst({raise,[Reg1,Reg2]},_,_,_) ->
- {bif,raise,{f,0},[Reg1,Reg2],{x,0}};
+ {raise,{f,0},[Reg1,Reg2],{x,0}}; % do NOT wrap this as a 'bif'
+ % as there is no raise/2 bif!
%%
%% New bit syntax instructions added in February 2004 (R10B).
--- otp-0704/lib/hipe/icode/hipe_beam_to_icode.erl.~1~ 2006-06-01 11:29:34.000000000 +0200
+++ otp-0704/lib/hipe/icode/hipe_beam_to_icode.erl 2006-08-03 12:48:43.000000000 +0200
@@ -575,7 +575,7 @@ trans_fun([{try_case_end,Arg}|Instructio
Fail = hipe_icode:mk_fail([V],error),
[Atom,Tuple,Fail | trans_fun(Instructions,Env)];
%%--- raise ---
-trans_fun([{bif,raise,{f,0},[Reg1,Reg2],{x,0}}|Instructions], Env) ->
+trans_fun([{raise,{f,0},[Reg1,Reg2],{x,0}}|Instructions], Env) ->
V1 = trans_arg(Reg1),
V2 = trans_arg(Reg2),
Fail = hipe_icode:mk_fail([V1,V2],rethrow),
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Thu Aug 03, 2006 12:17 pm |
|
|
|
Guest
|
On Fri, 21 Jul 2006 09:09:03 +0100, Trap Exit wrote:
(badly encoding-damaged)
>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}]} **
Thanks for reporting this. The bug has been fixed and the fix will
be included in the next OTP-R11B update. In the mean time you can
use the patch below.
/Mikael Pettersson
The HiPE Team
--- otp-0704/lib/compiler/src/beam_disasm.erl.~1~ 2006-06-27 15:58:34.000000000 +0200
+++ otp-0704/lib/compiler/src/beam_disasm.erl 2006-08-03 12:48:02.000000000 +0200
@@ -850,7 +850,8 @@ resolve_inst({try_case,[Reg]},_,_,_) ->
resolve_inst({try_case_end,[Arg]},_,_,_) ->
{try_case_end,resolve_arg(Arg)};
resolve_inst({raise,[Reg1,Reg2]},_,_,_) ->
- {bif,raise,{f,0},[Reg1,Reg2],{x,0}};
+ {raise,{f,0},[Reg1,Reg2],{x,0}}; % do NOT wrap this as a 'bif'
+ % as there is no raise/2 bif!
%%
%% New bit syntax instructions added in February 2004 (R10B).
--- otp-0704/lib/hipe/icode/hipe_beam_to_icode.erl.~1~ 2006-06-01 11:29:34.000000000 +0200
+++ otp-0704/lib/hipe/icode/hipe_beam_to_icode.erl 2006-08-03 12:48:43.000000000 +0200
@@ -575,7 +575,7 @@ trans_fun([{try_case_end,Arg}|Instructio
Fail = hipe_icode:mk_fail([V],error),
[Atom,Tuple,Fail | trans_fun(Instructions,Env)];
%%--- raise ---
-trans_fun([{bif,raise,{f,0},[Reg1,Reg2],{x,0}}|Instructions], Env) ->
+trans_fun([{raise,{f,0},[Reg1,Reg2],{x,0}}|Instructions], Env) ->
V1 = trans_arg(Reg1),
V2 = trans_arg(Reg2),
Fail = hipe_icode:mk_fail([V1,V2],rethrow),
Post recived from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|