--Signature=_Thu__18_Jun_2009_13_30_28_+0400_oTl50v21D0XYS7z7
Content-Type: text/plain; charset=US-ASCII
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi!

It looks like r21435 of ruby_1_8_7 broke ObjectSpace finalizers.
I don't entirely understand the code envolved, but it seems that
the following fragment is responsible for this:

% mark_tbl(finalizer_table, 0);
% st_foreach(finalizer_table, chain_finalized_object,
%     (st_data_t)&deferred_final_list);

Here, all objects in the finalizer table get marked, and the
chain_finalized_object function is called for each object in
the table.  However, chain_finalized_object immediately
returns if the object passes is marked:

% static int
% chain_finalized_object(st_data_t key, st_data_t val, st_data_t arg)
% {
%     RVALUE *p =3D (RVALUE *)key, **final_list =3D (RVALUE **)arg;
%     if ((p->as.basic.flags & (FL_FINALIZE|FL_MARK)) =3D=3D FL_FINALIZE) {
%        if (BUILTIN_TYPE(p) !=3D T_DEFERRED) {
%            p->as.free.flags =3D FL_MARK | T_DEFERRED; /* remain marked */
%           RDATA(p)->dfree =3D 0;
%        }
%        p->as.free.next =3D *final_list;
%        *final_list =3D p;
%     }
%     return ST_CONTINUE;
% }

Changing the test from '(p->as.basic.flags & (FL_FINALIZE|FL_MARK))' to
simple '(p->as.basic.flags & (FL_FINALIZE))' as before fixes the problem
for me, but I'm not sure this is the right solution.

The problem can be verified using the following simple snipplet:

% obj =3D "Test"
% handler =3D Proc.new { puts "Finalized!" }
% ObjectSpace.define_finalizer(obj, handler)

If you run this code in ruby 1.8.7 before r21435 it prints 'Finalized!'.
In newer version it is never called.

Thanks!

--=20
Stanislav Sedov
ST4096-RIPE

--Signature=_Thu__18_Jun_2009_13_30_28_+0400_oTl50v21D0XYS7z7
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----

iQIcBAEBAgAGBQJKOgk0AAoJEKN82nOYvCd0Pa4QAIuH7aglEAYOm6X1Do8tdEA7
EclItC4KNAdfGsZWl5IJ+xazEsi7hF4PfDfXzwrHKnrR50xEzKFOEktBw0xtcEVS
kLXvmjqeBQJRpN6f6PvxIIYaoUUE8sXq/3BzZiMIIuEpQHz1aeWm0EspTv2bj7wq
PpfQ0QaUHwmZ3Th/nDx0FwxenzEfyNFRwzUaYhUVOaqJsx62mjuPuJ9VuMNe5GJf
AIQcsqFR8NA0K182R7CXF1fbVT/XF5/GFGiYH84vLZQl5i0//akk2baLCSuv6DM2
nWPSy1CAw5C0OXKX1UgTkLK920KlodN36sA0r3caNKd/miQxISZKwBcpr/2GTtO4
ed9zr3jk5TDTVWU6ByoW1LPAEcvNpxDAzFNnG5kwqUuNCXwtpsUJH9+gkDWqpDwk
tlAfH9x2w9INu4MgJGA3hVJE3dEoObjkIyGBkj/j7a0PnbXsSX3QUgbRh0rjru8n
he1RuUdW5N90jWeP5pQgpKg34uLq968t42iCoLd55zChM/vTHnfGDLykTTGHMs2h
J6b95qRcz2qeVzdiDTvd85yO5RCDNv+DSlFOZLAUeTQ73adRzNxxfwBraLhkL9Sl
Pe6pF/G3UlCYtk+syFM088a9mGqPYkXoKyG8yJpFj6Kxq9qgCKZqO8M/OdbISYEx
vY0Mbv5xxfFhhQpNw174
=cbJu
-----END PGP SIGNATURE-----

--Signature=_Thu__18_Jun_2009_13_30_28_+0400_oTl50v21D0XYS7z7--