mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* vm_insnhelper.c (vm_push_frame): add CHECK_STACK_OVERFLOW.
[ruby-dev:39592] * eval.c (rb_longjmp): add 1 level backtrace for sysstack_error without calling any method to prevent further stack overflow. * eval.c (make_exception): don't call #exception for sysstack_error to prevent stack overflow. * proc.c (Init_Proc): don't freeze sysstack_error. * eval.c (rb_longjmp): move reentrant check after exception preparation. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
35da6fdcf1
commit
1e2dcdbd19
4 changed files with 38 additions and 14 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
||||||
|
Fri Nov 6 18:33:47 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm_insnhelper.c (vm_push_frame): add CHECK_STACK_OVERFLOW.
|
||||||
|
[ruby-dev:39592]
|
||||||
|
|
||||||
|
* eval.c (rb_longjmp): add 1 level backtrace for sysstack_error
|
||||||
|
without calling any method to prevent further stack overflow.
|
||||||
|
|
||||||
|
* eval.c (make_exception): don't call #exception for
|
||||||
|
sysstack_error to prevent stack overflow.
|
||||||
|
|
||||||
|
* proc.c (Init_Proc): don't freeze sysstack_error.
|
||||||
|
|
||||||
|
* eval.c (rb_longjmp): move reentrant check after exception
|
||||||
|
preparation.
|
||||||
|
|
||||||
Fri Nov 6 17:13:45 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Fri Nov 6 17:13:45 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/mkmf.rb (create_header): split the line by tabs.
|
* lib/mkmf.rb (create_header): split the line by tabs.
|
||||||
|
|
19
eval.c
19
eval.c
|
@ -358,12 +358,6 @@ rb_longjmp(int tag, volatile VALUE mesg)
|
||||||
const char *file;
|
const char *file;
|
||||||
volatile int line = 0;
|
volatile int line = 0;
|
||||||
|
|
||||||
if (rb_threadptr_set_raised(th)) {
|
|
||||||
th->errinfo = exception_error;
|
|
||||||
rb_threadptr_reset_raised(th);
|
|
||||||
JUMP_TAG(TAG_FATAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NIL_P(mesg))
|
if (NIL_P(mesg))
|
||||||
mesg = th->errinfo;
|
mesg = th->errinfo;
|
||||||
if (NIL_P(mesg)) {
|
if (NIL_P(mesg)) {
|
||||||
|
@ -373,6 +367,11 @@ rb_longjmp(int tag, volatile VALUE mesg)
|
||||||
file = rb_sourcefile();
|
file = rb_sourcefile();
|
||||||
if (file) line = rb_sourceline();
|
if (file) line = rb_sourceline();
|
||||||
if (file && !NIL_P(mesg)) {
|
if (file && !NIL_P(mesg)) {
|
||||||
|
if (mesg == sysstack_error) {
|
||||||
|
at = rb_enc_sprintf(rb_usascii_encoding(), "%s:%d", file, line);
|
||||||
|
rb_iv_set(mesg, "bt", at);
|
||||||
|
}
|
||||||
|
else {
|
||||||
at = get_backtrace(mesg);
|
at = get_backtrace(mesg);
|
||||||
if (NIL_P(at)) {
|
if (NIL_P(at)) {
|
||||||
at = rb_make_backtrace();
|
at = rb_make_backtrace();
|
||||||
|
@ -382,6 +381,7 @@ rb_longjmp(int tag, volatile VALUE mesg)
|
||||||
set_backtrace(mesg, at);
|
set_backtrace(mesg, at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!NIL_P(mesg)) {
|
if (!NIL_P(mesg)) {
|
||||||
th->errinfo = mesg;
|
th->errinfo = mesg;
|
||||||
}
|
}
|
||||||
|
@ -414,6 +414,12 @@ rb_longjmp(int tag, volatile VALUE mesg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rb_threadptr_set_raised(th)) {
|
||||||
|
th->errinfo = exception_error;
|
||||||
|
rb_threadptr_reset_raised(th);
|
||||||
|
JUMP_TAG(TAG_FATAL);
|
||||||
|
}
|
||||||
|
|
||||||
rb_trap_restore_mask();
|
rb_trap_restore_mask();
|
||||||
|
|
||||||
if (tag != TAG_FATAL) {
|
if (tag != TAG_FATAL) {
|
||||||
|
@ -520,6 +526,7 @@ make_exception(int argc, VALUE *argv, int isstr)
|
||||||
case 3:
|
case 3:
|
||||||
n = 1;
|
n = 1;
|
||||||
exception_call:
|
exception_call:
|
||||||
|
if (argv[0] == sysstack_error) return argv[0];
|
||||||
CONST_ID(exception, "exception");
|
CONST_ID(exception, "exception");
|
||||||
mesg = rb_check_funcall(argv[0], exception, n, argv+1);
|
mesg = rb_check_funcall(argv[0], exception, n, argv+1);
|
||||||
if (mesg == Qundef) {
|
if (mesg == Qundef) {
|
||||||
|
|
1
proc.c
1
proc.c
|
@ -2043,7 +2043,6 @@ Init_Proc(void)
|
||||||
sysstack_error = rb_exc_new3(rb_eSysStackError,
|
sysstack_error = rb_exc_new3(rb_eSysStackError,
|
||||||
rb_obj_freeze(rb_str_new2("stack level too deep")));
|
rb_obj_freeze(rb_str_new2("stack level too deep")));
|
||||||
OBJ_TAINT(sysstack_error);
|
OBJ_TAINT(sysstack_error);
|
||||||
OBJ_FREEZE(sysstack_error);
|
|
||||||
|
|
||||||
/* utility functions */
|
/* utility functions */
|
||||||
rb_define_global_function("proc", rb_block_proc, 0);
|
rb_define_global_function("proc", rb_block_proc, 0);
|
||||||
|
|
|
@ -26,9 +26,11 @@ vm_push_frame(rb_thread_t * th, const rb_iseq_t * iseq,
|
||||||
const VALUE *pc, VALUE *sp, VALUE *lfp,
|
const VALUE *pc, VALUE *sp, VALUE *lfp,
|
||||||
int local_size)
|
int local_size)
|
||||||
{
|
{
|
||||||
rb_control_frame_t * const cfp = th->cfp = th->cfp - 1;
|
rb_control_frame_t * const cfp = th->cfp - 1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
CHECK_STACK_OVERFLOW(th->cfp, local_size);
|
||||||
|
th->cfp = cfp;
|
||||||
/* setup vm value stack */
|
/* setup vm value stack */
|
||||||
|
|
||||||
/* nil initialize */
|
/* nil initialize */
|
||||||
|
|
Loading…
Reference in a new issue