ID:              33348
 User updated by: feldgendler at mail dot ru
 Reported By:     feldgendler at mail dot ru
-Status:          Bogus
+Status:          Open
 Bug Type:        Zend Engine 2 problem
 PHP Version:     5.0.4
 New Comment:

Simply reassigning $c1 won't break the destruction order because the
initial size of object_buckets is 1024, and it takes 1023 more objects
before object_buckets[0] is reused, but I got the idea. I didn't think
about reusing the slots in the object store, that's my fault.

This could be fixed by introducing a pair of references to each
object_store slot ("next created" and "previous created"), maintaining
these links when adding and deleting objects, and obeying this order
when calling the destructors at the end. (I can write a patch that does
it.) This would introduce a tiny overhead, but make the order of
destruction predictable. I think that making or not making it
predictable is rather a political question. I also think that it
deserves a broader discussion, could you direct me to the appropriate
mailing list? Or maybe this has already been discussed among PHP
developers, and the current state of things is a result of that
discussion.

I'm reopening this bug one last time just to draw your attention to my
comment because I'm not sure that you read this otherwise, sorry.
Please close it.


Previous Comments:
------------------------------------------------------------------------

[2005-06-15 09:55:44] [EMAIL PROTECTED]

Please read what Andi one more time:

There is no predefined order in which objects are destroyed. It is
random as object id's are re-used after objects have been destroyed.
There is no way (and I don't think there should be) to change this as
we
are efficiently using existing object space. You have to build your
own
mechanism (which should be quite easy) in order to order certain
destruction processes.

Even with your patch destruction order is random.
Hint: try to reassign $c1 with different object and see the result.

------------------------------------------------------------------------

[2005-06-15 09:48:02] feldgendler at mail dot ru

REOPEN
Please consider patching.

------------------------------------------------------------------------

[2005-06-15 09:47:22] feldgendler at mail dot ru

Sorry for the broken line in the patch above.

------------------------------------------------------------------------

[2005-06-15 09:46:39] feldgendler at mail dot ru

The answer on that bug was "it's not a bug". Well, I agree, it's not a
bug because the manual does not promise any certain order of
destruction. But I know a way to make it consistent with how it's done
in other object-oriented lanuages -- just apply this simple patch:

--- Zend/zend_objects_API.c.orig 2005-06-15 13:59:55.000000000 +0700
+++ Zend/zend_objects_API.c      2005-06-15 13:59:57.000000000 +0700
@@ -44,7 +44,7 @@
 {
        zend_uint i = 1;

-       for (i = 1; i < objects->top ; i++) {
+       for (i = objects->top - 1; i > 0; i--) {
                if (objects->object_buckets[i].valid) {
                        struct _store_object *obj =
&objects->object_buckets[i].bucket.obj;

------------------------------------------------------------------------

[2005-06-15 09:43:32] [EMAIL PROTECTED]

Search bug DB before submitting new bugs.
See bug #30823.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/33348

-- 
Edit this bug report at http://bugs.php.net/?id=33348&edit=1

Reply via email to