diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-24 07:43:13 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-24 07:43:13 +0000 |
commit | 757413f6bb6879a3bf92cf26fa4d0c9467cd84ff (patch) | |
tree | d8654e55dac758876a43d41d7f2c1839b401c0c7 /gc.c | |
parent | 9d803dfd5f1a57a6d07c27b0d95917165ba259dc (diff) | |
download | ruby-757413f6bb6879a3bf92cf26fa4d0c9467cd84ff.tar.gz |
Rvert r37827 and r37828
Revert "Fix finalize of WeakRef"
This causes segv on rubyspec.
http://u64.rubyci.org/~chkbuild/ruby-trunk/log/20121124T050101Z.log.html.gz
you can reproduce by
make test-rubyspec MSPECOPT='-V library/weakref'
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r-- | gc.c | 33 |
1 files changed, 15 insertions, 18 deletions
@@ -3749,40 +3749,37 @@ wmap_allocate(VALUE klass) static int wmap_final_func(st_data_t *key, st_data_t *value, st_data_t arg, int existing) { - VALUE wmap, ary; + VALUE obj, ary; if (!existing) return ST_STOP; - wmap = (VALUE)arg, ary = (VALUE)*value; - rb_ary_delete(ary, wmap); + obj = (VALUE)*key, ary = (VALUE)*value; + rb_ary_delete(ary, obj); if (!RARRAY_LEN(ary)) return ST_DELETE; return ST_CONTINUE; } static VALUE -wmap_finalize(VALUE self, VALUE objid) +wmap_finalize(VALUE self, VALUE obj) { - st_data_t orig, wmap, data; - VALUE obj, rids; + st_data_t data; + VALUE rids; long i; struct weakmap *w; TypedData_Get_Struct(self, struct weakmap, &weakmap_type, w); - /* Get reference from object id. */ - obj = objid ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */ + obj = NUM2PTR(obj); - /* obj is original referenced object and/or weak reference. */ - orig = (st_data_t)obj; - if (st_delete(w->obj2wmap, &orig, &data)) { + data = (st_data_t)obj; + if (st_delete(w->obj2wmap, &data, &data)) { rids = (VALUE)data; for (i = 0; i < RARRAY_LEN(rids); ++i) { - wmap = (st_data_t)RARRAY_PTR(rids)[i]; - st_delete(w->wmap2obj, &wmap, NULL); + data = (st_data_t)RARRAY_PTR(rids)[i]; + st_delete(w->wmap2obj, &data, NULL); } } - wmap = (st_data_t)obj; - if (st_delete(w->wmap2obj, &wmap, &orig)) { - wmap = (st_data_t)obj; - st_update(w->obj2wmap, orig, wmap_final_func, wmap); + data = (st_data_t)obj; + if (st_delete(w->wmap2obj, &data, &data)) { + st_update(w->obj2wmap, (st_data_t)obj, wmap_final_func, 0); } return self; } @@ -3804,7 +3801,7 @@ wmap_aset(VALUE self, VALUE wmap, VALUE orig) rids = rb_ary_tmp_new(1); st_insert(w->obj2wmap, (st_data_t)orig, (st_data_t)rids); } - rb_ary_push(rids, wmap); + rb_ary_push(rids, orig); st_insert(w->wmap2obj, (st_data_t)wmap, (st_data_t)orig); return nonspecial_obj_id(orig); } |