1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Crash more nicely when the VM isn't fully set up

If we crash but the VM isn't fully alive, we can get an infinite loop.
This commit is contained in:
Aaron Patterson 2021-06-10 16:03:11 -07:00
parent 929cc615a7
commit d74e5d5b4f
No known key found for this signature in database
GPG key ID: 953170BCB4FFAFC6

View file

@ -1062,36 +1062,38 @@ rb_vm_bugreport(const void *ctx)
LIMITED_NAME_LENGTH(name), RSTRING_PTR(name)); LIMITED_NAME_LENGTH(name), RSTRING_PTR(name));
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
fprintf(stderr, "* Loaded features:\n\n"); if (vm->loaded_features) {
for (i=0; i<RARRAY_LEN(vm->loaded_features); i++) { fprintf(stderr, "* Loaded features:\n\n");
name = RARRAY_AREF(vm->loaded_features, i); for (i=0; i<RARRAY_LEN(vm->loaded_features); i++) {
if (RB_TYPE_P(name, T_STRING)) { name = RARRAY_AREF(vm->loaded_features, i);
fprintf(stderr, " %4d %.*s\n", i, if (RB_TYPE_P(name, T_STRING)) {
LIMITED_NAME_LENGTH(name), RSTRING_PTR(name)); fprintf(stderr, " %4d %.*s\n", i,
} LIMITED_NAME_LENGTH(name), RSTRING_PTR(name));
else if (RB_TYPE_P(name, T_CLASS) || RB_TYPE_P(name, T_MODULE)) { }
const char *const type = RB_TYPE_P(name, T_CLASS) ? else if (RB_TYPE_P(name, T_CLASS) || RB_TYPE_P(name, T_MODULE)) {
"class" : "module"; const char *const type = RB_TYPE_P(name, T_CLASS) ?
name = rb_search_class_path(rb_class_real(name)); "class" : "module";
if (!RB_TYPE_P(name, T_STRING)) { name = rb_search_class_path(rb_class_real(name));
fprintf(stderr, " %4d %s:<unnamed>\n", i, type); if (!RB_TYPE_P(name, T_STRING)) {
continue; fprintf(stderr, " %4d %s:<unnamed>\n", i, type);
} continue;
fprintf(stderr, " %4d %s:%.*s\n", i, type, }
LIMITED_NAME_LENGTH(name), RSTRING_PTR(name)); fprintf(stderr, " %4d %s:%.*s\n", i, type,
} LIMITED_NAME_LENGTH(name), RSTRING_PTR(name));
else { }
VALUE klass = rb_search_class_path(rb_obj_class(name)); else {
if (!RB_TYPE_P(klass, T_STRING)) { VALUE klass = rb_search_class_path(rb_obj_class(name));
fprintf(stderr, " %4d #<%p:%p>\n", i, if (!RB_TYPE_P(klass, T_STRING)) {
(void *)CLASS_OF(name), (void *)name); fprintf(stderr, " %4d #<%p:%p>\n", i,
continue; (void *)CLASS_OF(name), (void *)name);
} continue;
fprintf(stderr, " %4d #<%.*s:%p>\n", i, }
LIMITED_NAME_LENGTH(klass), RSTRING_PTR(klass), fprintf(stderr, " %4d #<%.*s:%p>\n", i,
(void *)name); LIMITED_NAME_LENGTH(klass), RSTRING_PTR(klass),
} (void *)name);
} }
}
}
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }