# Abort in rescue

#1

e\$B1sF#\$G\$9!#e(B

1.8 e\$B\$G\$Oe(B rescue e\$B\$NCf\$Ge(B abort
e\$B\$9\$k\$H%9%?%C%/%H%l!<%9\$r=P\$9\$h\$&\$G\$9\$,!"e(B
1.9 e\$B\$G\$O2?\$bI=<(\$5\$l\$J\$/\$J\$C\$F\$\$\$^\$9!#e(B

\$ ruby18 -e ‘begin; raise; rescue; abort; end’
-e:1: unhandled exception

\$ ruby19 -e ‘begin; raise; rescue; abort; end’

rb_f_abort
e\$B\$r8+\$k\$H%9%?%C%/%H%l!<%9\$r=P\$=\$&\$H\$9\$k%3!<%I\$,;D\$C\$F\$\$j!"e(B
e\$B0U?^E
\$J5sF0JQ99\$K\$O8+\$(\$^\$;\$s\$G\$7\$?!#e(B

e\$B%9%?%C%/%H%l!<%9\$r=P\$9\$h\$&\$K\$9\$k\$N\$O4JC1\$G\$9\$,!“e(B1.9 e\$B\$G\$Oe(B \$!
= nil e\$B\$,e(B
e\$B6X;\$5\$l\$F\$\$\$k\$?\$a!"\$3\$N5sF0\$rM^;\$9\$kJ}K!\$,\$”\$j\$^\$;\$s!#e(B

\$ ruby18 -e ‘begin; raise; rescue; \$! = nil; abort; end’

\$ ruby19 -e ‘begin; raise; rescue; \$! = nil; abort; end’
-e:1:in `rescue in <main>': \$! is a read-only variable (NameError) from -e:1:in`

e\$B\$I\$&\$7\$?\$b\$s\$G\$7\$g\$&\$+!#e(B
e\$B0J2<\$O%9%?%C%/%H%l!<%9\$r=P\$9\$h\$&\$K\$7!"e(B\$!
e\$B\$X\$NBeF~\$r5v2D\$9\$k\$h\$&\$Ke(B
e\$B\$9\$k%Q%C%A\$G\$9!#e(B

# Index: eval.c

— eval.c (revision 19769)
+++ eval.c (working copy)
@@ -426,7 +426,7 @@
rb_raise(rb_eInterrupt, “%s”, “”);
}

-static VALUE get_errinfo(void);
+VALUE get_errinfo(void);

/*

• call-seq:
@@ -953,7 +953,7 @@
return 0;
}

-static VALUE
+VALUE
get_errinfo(void)
{
VALUE *ptr = errinfo_place();
@@ -971,7 +971,6 @@
return get_errinfo();
}

-#if 0
static void
errinfo_setter(VALUE val, ID id, VALUE *var)
{
@@ -988,7 +987,6 @@
}
}
}
-#endif

VALUE
rb_errinfo(void)
@@ -1119,7 +1117,7 @@
Init_eval(void)
{
rb_define_virtual_variable("\$@", errat_getter, errat_setter);

• rb_define_virtual_variable("\$!", errinfo_getter, 0);
• rb_define_virtual_variable("\$!", errinfo_getter, errinfo_setter);

rb_define_global_function(“iterator?”, rb_f_block_given_p, 0);
rb_define_global_function(“block_given?”, rb_f_block_given_p, 0);
Index: process.c
===================================================================
— process.c (revision 19769)
+++ process.c (working copy)
@@ -2534,10 +2534,12 @@
rb_f_abort(int argc, VALUE *argv)
{
extern void ruby_error_print(void);

• extern VALUE get_errinfo(void);

rb_secure(4);
if (argc == 0) {

• VALUE errinfo = GET_THREAD()->errinfo = get_errinfo();
• if (!NIL_P(errinfo)) {
ruby_error_print();
}
rb_exit(EXIT_FAILURE);

#2

e\$B1sF#\$G\$9!#e(B

e\$B\$3\$N7o!"H?1~\$r\$*4j\$\$\$7\$^\$9!#e(B > e\$B\$5\$5\$@\$5\$se(B

#3

e\$B1sF#\$G\$9!#e(B

rb_f_abort e\$B\$r8+\$k\$H%9%?%C%/%H%l!<%9\$r=P\$=\$&\$H\$9\$k%3!<%I\$,;D\$C\$F\$\$j!"e(B
e\$B0U?^E
\$J5sF0JQ99\$K\$O8+\$(\$^\$;\$s\$G\$7\$?!#e(B

e\$B!!\$3\$C\$A\$O%P%0\$H\$7\$F9M\$(\$k\$H\$7\$F!%e(B

e\$B\$O\$\$!#e(B

e\$B%9%?%C%/%H%l!<%9\$r=P\$9\$h\$&\$K\$9\$k\$N\$O4JC1\$G\$9\$,!“e(B1.9 e\$B\$G\$Oe(B \$! = nil e\$B\$,e(B
e\$B6X;\$5\$l\$F\$\$\$k\$?\$a!"\$3\$N5sF0\$rM^;\$9\$kJ}K!\$,\$”\$j\$^\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