summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-15 05:38:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-15 05:38:07 +0000
commit584829aa814a1104205ab85cefcf245f8c118987 (patch)
treec966812ecde6bfc90b18530dbaa43ade185f435e
parent073515a6499bc2ccc6a20891c4c82a5afb91b2a7 (diff)
downloadruby-584829aa814a1104205ab85cefcf245f8c118987.tar.gz
* vm.c (vm_backtrace_each): get rid of use of malloc from signal
handler by using ruby_engine_name. [ruby-core:29497] * vm_eval.c (print_backtrace): file may be nil when segfaulted in very early stage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--version.c3
-rw-r--r--vm.c3
-rw-r--r--vm_eval.c12
4 files changed, 22 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 5c61fba7cc..63f6264e0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Apr 15 14:38:03 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * vm.c (vm_backtrace_each): get rid of use of malloc from signal
+ handler by using ruby_engine_name. [ruby-core:29497]
+
+ * vm_eval.c (print_backtrace): file may be nil when segfaulted in
+ very early stage.
+
Thu Apr 15 11:51:49 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* common.mk (help): small fix.
diff --git a/version.c b/version.c
index 1dc64d9e9c..a0008efad6 100644
--- a/version.c
+++ b/version.c
@@ -57,6 +57,7 @@ const int ruby_patchlevel = RUBY_PATCHLEVEL;
const char ruby_description[] = RUBY_DESCRIPTION;
const char ruby_copyright[] = RUBY_COPYRIGHT;
const char ruby_engine[] = "ruby";
+VALUE ruby_engine_name = Qnil;
const char ruby_initial_load_paths[] =
#ifndef NO_INITIAL_LOAD_PATH
@@ -95,7 +96,7 @@ Init_version(void)
rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
- rb_define_global_const("RUBY_ENGINE", MKSTR(engine));
+ rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
}
void
diff --git a/vm.c b/vm.c
index 678fcb8762..3a1e37f9ff 100644
--- a/vm.c
+++ b/vm.c
@@ -732,8 +732,9 @@ vm_backtrace_each(rb_thread_t *th, int lev, rb_backtrace_iter_func *iter, void *
}
else if (RUBYVM_CFUNC_FRAME_P(cfp)) {
ID id;
+ extern VALUE ruby_engine_name;
- if (NIL_P(file)) file = rb_str_new_cstr("ruby");
+ if (NIL_P(file)) file = ruby_engine_name;
if (cfp->me->def)
id = cfp->me->def->original_id;
else
diff --git a/vm_eval.c b/vm_eval.c
index ea72365d9d..fefe6d6dfd 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1573,8 +1573,16 @@ rb_f_caller(int argc, VALUE *argv)
static int
print_backtrace(void *arg, VALUE file, int line, VALUE method)
{
- fprintf((FILE *)arg, "\tfrom %s:%d:in `%s'\n",
- RSTRING_PTR(file), line, RSTRING_PTR(method));
+ FILE *fp = arg;
+ const char *filename = NIL_P(file) ? "ruby" : RSTRING_PTR(file);
+ if (NIL_P(method)) {
+ fprintf(fp, "\tfrom %s:%d:in unknown method\n",
+ filename, line);
+ }
+ else {
+ fprintf(fp, "\tfrom %s:%d:in `%s'\n",
+ filename, line, RSTRING_PTR(method));
+ }
return FALSE;
}