ruby-changes:13880
From: matz <ko1@a...>
Date: Sat, 7 Nov 2009 11:45:24 +0900 (JST)
Subject: [ruby-changes:13880] Ruby:r25680 (trunk): * vm_insnhelper.c (vm_push_frame): add CHECK_STACK_OVERFLOW.
matz 2009-11-07 11:45:08 +0900 (Sat, 07 Nov 2009) New Revision: 25680 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25680 Log: * 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. Modified files: trunk/ChangeLog trunk/eval.c trunk/proc.c trunk/vm_insnhelper.c Index: ChangeLog =================================================================== --- ChangeLog (revision 25679) +++ ChangeLog (revision 25680) @@ -1,3 +1,19 @@ +Fri Nov 6 18:33:47 2009 Yukihiro Matsumoto <matz@r...> + + * 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@r...> * lib/mkmf.rb (create_header): split the line by tabs. Index: proc.c =================================================================== --- proc.c (revision 25679) +++ proc.c (revision 25680) @@ -2043,7 +2043,6 @@ sysstack_error = rb_exc_new3(rb_eSysStackError, rb_obj_freeze(rb_str_new2("stack level too deep"))); OBJ_TAINT(sysstack_error); - OBJ_FREEZE(sysstack_error); /* utility functions */ rb_define_global_function("proc", rb_block_proc, 0); Index: eval.c =================================================================== --- eval.c (revision 25679) +++ eval.c (revision 25680) @@ -358,12 +358,6 @@ const char *file; 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)) mesg = th->errinfo; if (NIL_P(mesg)) { @@ -373,13 +367,19 @@ file = rb_sourcefile(); if (file) line = rb_sourceline(); if (file && !NIL_P(mesg)) { - at = get_backtrace(mesg); - if (NIL_P(at)) { - at = rb_make_backtrace(); - if (OBJ_FROZEN(mesg)) { - mesg = rb_obj_dup(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); + if (NIL_P(at)) { + at = rb_make_backtrace(); + if (OBJ_FROZEN(mesg)) { + mesg = rb_obj_dup(mesg); + } + set_backtrace(mesg, at); } - set_backtrace(mesg, at); } } if (!NIL_P(mesg)) { @@ -414,6 +414,12 @@ } } + if (rb_threadptr_set_raised(th)) { + th->errinfo = exception_error; + rb_threadptr_reset_raised(th); + JUMP_TAG(TAG_FATAL); + } + rb_trap_restore_mask(); if (tag != TAG_FATAL) { @@ -520,6 +526,7 @@ case 3: n = 1; exception_call: + if (argv[0] == sysstack_error) return argv[0]; CONST_ID(exception, "exception"); mesg = rb_check_funcall(argv[0], exception, n, argv+1); if (mesg == Qundef) { Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 25679) +++ vm_insnhelper.c (revision 25680) @@ -26,9 +26,11 @@ const VALUE *pc, VALUE *sp, VALUE *lfp, 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; + CHECK_STACK_OVERFLOW(th->cfp, local_size); + th->cfp = cfp; /* setup vm value stack */ /* nil initialize */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/