[前][次][番号順一覧][スレッド一覧]

ruby-changes:34508

From: nobu <ko1@a...>
Date: Sat, 28 Jun 2014 01:28:46 +0900 (JST)
Subject: [ruby-changes:34508] nobu:r46589 (trunk): eval.c: reduce machine stack overflow backtrace

nobu	2014-06-28 01:28:35 +0900 (Sat, 28 Jun 2014)

  New Revision: 46589

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46589

  Log:
    eval.c: reduce machine stack overflow backtrace
    
    * eval.c (setup_exception): revert r46531 to reduce backtrace at
      machine stack overflow.

  Modified files:
    trunk/eval.c
Index: eval.c
===================================================================
--- eval.c	(revision 46588)
+++ eval.c	(revision 46589)
@@ -492,7 +492,19 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L492
     file = rb_sourcefile();
     if (file) line = rb_sourceline();
     if (file && !NIL_P(mesg)) {
-	if (sysstack_error_p(mesg) || NIL_P(at = get_backtrace(mesg))) {
+	if (mesg == sysstack_error) {
+	    /* machine stack overflow, reduce too long backtrace */
+	    ID func = rb_frame_this_func();
+	    at = rb_enc_sprintf(rb_usascii_encoding(), "%s:%d", file, line);
+	    if (func) {
+		VALUE name = rb_id2str(func);
+		if (name) rb_str_catf(at, ":in `%"PRIsVALUE"'", name);
+	    }
+	    at = rb_ary_new3(1, at);
+	    mesg = rb_obj_dup(mesg);
+	    rb_iv_set(mesg, "bt", at);
+	}
+	else if (sysstack_error_p(mesg) || NIL_P(at = get_backtrace(mesg))) {
 	    at = rb_vm_backtrace_object();
 	    if (OBJ_FROZEN(mesg)) {
 		mesg = rb_obj_dup(mesg);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]