diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-15 09:17:06 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-15 09:17:06 +0000 |
commit | 9b45b336ee97477b9c8a81143ee47c52d801412b (patch) | |
tree | b40d5a5f32138109f5c9b0006d6d90f6529a621e /gc.c | |
parent | e7a660a3cfe9a8747b0a5f5b0c88019f5a19bbce (diff) |
* vm_core.h (rb_vm_t), vm.c (rb_vm_mark): moved preallocated special
exceptions.
* eval.c (Init_eval), gc.c (Init_GC), proc.c (Init_Proc): freeze
preallocated special exceptions.
* eval.c (rb_longjmp): duplicate the thrown exception to set backtrace
if it was frozen.
* gc.c (rb_memerror): raise nomem_error without backtrace if failed to
make backtrace.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -84,7 +84,7 @@ void *alloca (); #endif #endif -static VALUE nomem_error; +#define nomem_error GET_VM()->special_exceptions[ruby_error_nomemory] #define MARK_STACK_MAX 1024 @@ -265,6 +265,11 @@ rb_memerror(void) fprintf(stderr, "[FATAL] failed to allocate memory\n"); exit(EXIT_FAILURE); } + if (rb_thread_raised_p(th, RAISED_NOMEMORY)) { + rb_thread_raised_clear(th); + GET_THREAD()->errinfo = nomem_error; + JUMP_TAG(TAG_RAISE); + } rb_thread_raised_set(th, RAISED_NOMEMORY); rb_exc_raise(nomem_error); } @@ -2394,8 +2399,9 @@ Init_GC(void) rb_define_module_function(rb_mObSpace, "_id2ref", id2ref, 1); - rb_global_variable(&nomem_error); nomem_error = rb_exc_new2(rb_eNoMemError, "failed to allocate memory"); + OBJ_TAINT(nomem_error); + OBJ_FREEZE(nomem_error); rb_define_method(rb_mKernel, "hash", rb_obj_id, 0); rb_define_method(rb_mKernel, "__id__", rb_obj_id, 0); |