# I caught the aggregation bug!

- Thread: https://externals.io/message/1933
- Original archive: https://news-web.php.net/php.internals/1933
- Started by Wei He on 2003-05-23T15:44:52+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #1933 — Wei He — 2003-05-23T15:44:52+00:00

URL: https://externals.io/message/1933#1933

Hi,

This short script can reproduce the aggregation bug I reported above.

class bar {
 
   function doit()
   {
      print " Doing...\n";
   }
}

class foo {

   function foo()
   {
       print_r(aggregation_info($this));
       aggregate($this, "bar");
   }
   
   function spawn()
   {
       return new foo();
   }
}

$a = new foo();
$a->doit();
$b = $a->spawn();
$b->doit();
unset($a);
$c = $b->spawn();
$c->doit();

Besides 'unset($a)', '$a = new foo()' will also cause the same problem.

Wei He

---

## #2311 — Wei He — 2003-06-13T09:22:43+00:00

URL: https://externals.io/message/1933#2311 · In reply to: #1933

Hi,

I didn't receive and emails regarding to my discovery of the bug. If it 
wasn't because the mailing list or my email server's problem, it would
turned out to be that nobody cares about it. 

Then what if, according to my own debugging, the problem is related
to zend hash?

I guess the answer to the following error is that unset($a) freed the 
object but not the all the hash tables (aggretated methods) associated 
with it.

So a new object after the unset will reuse the same memory location and
zend_hash_add will return a failure.

zend_hash.c: in function zend_hash_add_or_update

	while (p != NULL) {
		if ((p->h == h) && (p->nKeyLength == nKeyLength)) {
			if (!memcmp(p->arKey, arKey, nKeyLength)) {
				if (flag & HASH_ADD) {
					return FAILURE;
				}
				HANDLE_BLOCK_INTERRUPTIONS();

Can anyone understading zend hash functions well check why 
this would happen? 

Shouldn't unset($a) clean everything related to it?

Please! I can't live without aggregation and I can't
work any longer due to the bug.

If you really don't think it a bug. Would anyone kindly reply 
me a message so that at least I know you guys have received my 
report?

Wei He




> Hi,
> 
> This short script can reproduce the aggregation bug I reported above.
> 
> class bar {
>  
>    function doit()
>    {
>       print " Doing...\n";
>    }
> }
> 
> class foo {
> 
>    function foo()
>    {
>        print_r(aggregation_info($this));
>        aggregate($this, "bar");
>    }
>    
>    function spawn()
>    {
>        return new foo();
>    }
> }
> 
> $a = new foo();
> $a->doit();
> $b = $a->spawn();
> $b->doit();
> unset($a);
> $c = $b->spawn();
> $c->doit();
> 
> Besides 'unset($a)', '$a = new foo()' will also cause the same problem.
> 
> Wei He

---

## #2314 — Andrei Zmievski — 2003-06-13T14:28:25+00:00

URL: https://externals.io/message/1933#2314 · In reply to: #2311

Didn't you get my email? I fixed the bug, as far as I know. Try the
latest PHP_4 or PHP_4_3 CVS.


> Hi,
> 
> I didn't receive and emails regarding to my discovery of the bug. If it 
> wasn't because the mailing list or my email server's problem, it would
> turned out to be that nobody cares about it. 

-Andrei
* Quantum Mechanics: The Dreams of Which Stuff is Made. *
