ruby-changes:15447
From: nobu <ko1@a...>
Date: Thu, 15 Apr 2010 14:38:27 +0900 (JST)
Subject: [ruby-changes:15447] Ruby:r27345 (trunk): * vm.c (vm_backtrace_each): get rid of use of malloc from signal
nobu 2010-04-15 14:38:07 +0900 (Thu, 15 Apr 2010) New Revision: 27345 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27345 Log: * 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. Modified files: trunk/ChangeLog trunk/version.c trunk/vm.c trunk/vm_eval.c Index: ChangeLog =================================================================== --- ChangeLog (revision 27344) +++ ChangeLog (revision 27345) @@ -1,3 +1,11 @@ +Thu Apr 15 14:38:03 2010 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * common.mk (help): small fix. Index: vm_eval.c =================================================================== --- vm_eval.c (revision 27344) +++ vm_eval.c (revision 27345) @@ -1573,8 +1573,16 @@ 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; } Index: vm.c =================================================================== --- vm.c (revision 27344) +++ vm.c (revision 27345) @@ -732,8 +732,9 @@ } 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 Index: version.c =================================================================== --- version.c (revision 27344) +++ version.c (revision 27345) @@ -57,6 +57,7 @@ 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 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/