aboutsummaryrefslogtreecommitdiffstats
path: root/eval.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-27 16:28:35 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-27 16:28:35 +0000
commit402d33fc44b20779a90e9381cfd4f52154dfd872 (patch)
tree8a99e6cbbccadd694fc5a5cc4bab604d3dc184da /eval.c
parent9a4f9f3424d6e0b785b2f4cfbcec3f2c2d0ecdcf (diff)
downloadruby-402d33fc44b20779a90e9381cfd4f52154dfd872.tar.gz
eval.c: reduce machine stack overflow backtrace
* eval.c (setup_exception): revert r46531 to reduce backtrace at machine stack overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r--eval.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/eval.c b/eval.c
index 1cf75c458c..ee47a44da4 100644
--- a/eval.c
+++ b/eval.c
@@ -492,7 +492,19 @@ setup_exception(rb_thread_t *th, int tag, volatile VALUE mesg, VALUE cause)
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);