summaryrefslogtreecommitdiff
path: root/vm_eval.c
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 /vm_eval.c
parent073515a6499bc2ccc6a20891c4c82a5afb91b2a7 (diff)
* 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
Diffstat (limited to 'vm_eval.c')
-rw-r--r--vm_eval.c12
1 files changed, 10 insertions, 2 deletions
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;
}