# New Ticket Created by "Julian Fondren" # Please include the string: [perl #41726] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=41726 >
Currently, evaluating this: function bad (n) return n * bad(n) end bad(2) will cause lua to produce -- infinitely, and very quickly -- ungraceful error messages. (It will do this on any excess-recursion error -- I first saw this behavior when I passed too-large a number to a simple factorial function.) The attached patch causes lua to generate .pir files that push this exception handler before evaluating any compiled-lua code: root_exception_handler: get_results '(0, 0)', $P0, $S0 $S0 = $P0[0] print "Unhandled exception: " print $S0 print "\n" exit 1 I already sent this to Klaas-Jan Stol <[EMAIL PROTECTED]> , but when I didn't get a reply or see the change in svn after a few days, I RTFM'd on contributing patches. Cheers, Julian
--- languages/lua/Lua/pir.pm 2007-03-07 16:26:54.000000000 +0900 +++ languages/lua/Lua/pir.pm 2007-03-07 16:26:49.000000000 +0900 @@ -22,6 +22,7 @@ $P0 = new .Array set $P0, $I0 $I1 = 0 + push_eh root_exception_handler L1: unless $I1 < $I0 goto L2 $S0 = shift args @@ -43,7 +44,16 @@ load_bytecode 'languages/lua/lib/luaos.pbc' load_bytecode 'languages/lua/lib/luadebug.pbc' load_bytecode 'languages/lua/lib/luaperl.pbc' - _main($P0 :flat) + .return _main($P0 :flat) + + # a convenient place? +root_exception_handler: + get_results '(0, 0)', $P0, $S0 + $S0 = $P0[0] + print "Unhandled exception: " + print $S0 + print "\n" + exit 1 .end .sub '__onload' :anon :init Index: CREDITS =================================================================== --- CREDITS (revision 17374) +++ CREDITS (working copy) @@ -313,6 +313,9 @@ N: Juergen Boemmels D: Parrot I/O; macro stuff in assembler. +N: Julian Fondren +E: [EMAIL PROTECTED] + N: Karl Forner D: shootout examples testing E: [EMAIL PROTECTED]