summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-30 07:19:16 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-30 07:19:16 +0000
commit981f9c52c6b0d7197e098ae9a0375485cf0c9c0c (patch)
tree67dcd293af1c70993db288c33f7e9ff85b603e53
parentb5d8a0b339321c1ba1453d9549d074148079707b (diff)
vm_dump.c: no methods in segv handler
* vm_dump.c (rb_vm_bugreport): get rid of calling methods in sigsegv handler. based on a patch by charliesome (Charlie Somerville) [ruby-core:49573] [Bug #7402] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_rubyoptions.rb7
-rw-r--r--vm_dump.c16
3 files changed, 27 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index a670ec9..57554fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Nov 30 16:19:14 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * vm_dump.c (rb_vm_bugreport): get rid of calling methods in sigsegv
+ handler. based on a patch by charliesome (Charlie Somerville)
+ [ruby-core:49573] [Bug #7402]
+
Fri Nov 30 16:05:44 2012 Eric Hodel <drbrain@segment7.net>
* NEWS: Added RubyGems 2.0.0
diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb
index 16656f0..9e8978f 100644
--- a/test/ruby/test_rubyoptions.rb
+++ b/test/ruby/test_rubyoptions.rb
@@ -508,6 +508,13 @@ class TestRubyOptions < Test::Unit::TestCase
)x,
nil,
opts)
+
+ bug7402 = '[ruby-core:49573]'
+ status = assert_in_out_err(['-e', 'class Bogus; def to_str; exit true; end; end',
+ '-e', '$".unshift Bogus.new',
+ '-e', 'Process.kill :SEGV, $$'],
+ "", //, /#<Bogus:/)
+ assert_not_predicate(status, :success?, "segv but success #{bug7402}")
end
def test_DATA
diff --git a/vm_dump.c b/vm_dump.c
index 1c1a36e..c2fa33f 100644
--- a/vm_dump.c
+++ b/vm_dump.c
@@ -675,14 +675,26 @@ rb_vm_bugreport(void)
if (vm) {
int i;
VALUE name;
+ long len;
+ const int max_name_length = 1024;
+# define LIMITED_NAME_LENGTH(s) \
+ (((len = RSTRING_LEN(s)) > max_name_length) ? max_name_length : (int)len)
name = vm->progname;
- fprintf(stderr, "* Loaded script: %s\n", StringValueCStr(name));
+ fprintf(stderr, "* Loaded script: %.*s\n",
+ LIMITED_NAME_LENGTH(name), RSTRING_PTR(name));
fprintf(stderr, "\n");
fprintf(stderr, "* Loaded features:\n\n");
for (i=0; i<RARRAY_LEN(vm->loaded_features); i++) {
name = RARRAY_PTR(vm->loaded_features)[i];
- fprintf(stderr, " %4d %s\n", i, StringValueCStr(name));
+ if (RB_TYPE_P(name, T_STRING)) {
+ fprintf(stderr, " %4d %.*s\n", i,
+ LIMITED_NAME_LENGTH(name), RSTRING_PTR(name));
+ }
+ else {
+ fprintf(stderr, " %4d #<%s:%p>\n", i,
+ rb_class2name(CLASS_OF(name)), (void *)name);
+ }
}
fprintf(stderr, "\n");
}