php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61384 Related to bug #61219, Reflection*->getName() returns false
Submitted: 2012-03-14 06:47 UTC Modified: 2012-07-17 10:18 UTC
Votes:11
Avg. Score:4.2 ± 0.9
Reproduced:10 of 10 (100.0%)
Same Version:3 (30.0%)
Same OS:9 (90.0%)
From: peacech at gmail dot com Assigned: ab
Status: Closed Package: APC (PECL)
PHP Version: 5.4.0 OS: Linux
Private report: No CVE-ID:
 [2012-03-14 06:47 UTC] peacech at gmail dot com
Description:
------------
At least the method getName() in ReflectionMethod and ReflectionParameters always returns false. I haven't check other reflection classes.

This only happens when apc is loaded (svn r324146)

Copying newp->arKey like shown in below diff fixes the problem but I'm not sure if it's the correct way.

--- apc_compile.c	(revision 324205)
+++ apc_compile.c	(working copy)
@@ -889,6 +889,7 @@
             CHECK((newp = (Bucket*) apc_pmemcpy(curr, sizeof(Bucket), pool TSRMLS_CC)));
         } else if (IS_INTERNED(curr->arKey)) {
             CHECK((newp = (Bucket*) apc_pmemcpy(curr, sizeof(Bucket), pool TSRMLS_CC)));
+            CHECK((newp->arKey = (char*) apc_pmemcpy(curr->arKey, curr->nKeyLength, pool TSRMLS_CC)));
 #ifndef ZTS
         } else if (pool->type != APC_UNPOOL) {
             char *arKey;

Test script:
---------------
<?php

function a() { }
var_dump((new ReflectionFunction($a0))->getName());

Expected result:
----------------
"a"

Actual result:
--------------
false

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-14 07:14 UTC] peacech at gmail dot com
After more test, the above patch does not solve the problem. So I update apc to r323991, and the problem is gone, and neither do I have any method not found error.
 [2012-03-19 08:12 UTC] nikic@php.net
Can I close this bug as the issue is gone?
 [2012-03-19 08:24 UTC] peacech at gmail dot com
Hi,

The bug is still there. When I said it's gone, I mean that it's not there in previous revision.

host:hitachi | time:03:22 PM | jobs:0 | user:root 
~/compile/php/5.4/ext/apc_svn> svn info
Path: .
Working Copy Root Path: /root/compile/php/5.4/ext/apc_svn
URL: https://svn.php.net/repository/pecl/apc/trunk
Repository Root: https://svn.php.net/repository
Repository UUID: c90b9560-bf6c-de11-be94-00142212c4b1
Revision: 324351
Node Kind: directory
Schedule: normal
Last Changed Author: mike
Last Changed Rev: 324329
Last Changed Date: 2012-03-18 22:29:37 +0700 (Sun, 18 Mar 2012)


host:hitachi | time:03:22 PM | jobs:0 | user:root 
~/compile/php/5.4/ext/apc_svn> cat /tmp/test.php
<?php

function a() { }
var_dump((new ReflectionFunction('a'))->getName());

host:hitachi | time:03:22 PM | jobs:0 | user:root 
~/compile/php/5.4/ext/apc_svn> php /tmp/test.php
bool(false)
 [2012-04-12 08:46 UTC] peacech at gmail dot com
I have isolated where the problem is:

in apc_string.c (function apc_copy_internal_strings)

if (ce->name) {
            //ZEND_STR_INTERN_DUP(ce->name, ce->name_length)
            ce->name = apc_new_interned_string(ce->name, ce->name_length TSRMLS_CC);
}

 if (info->name) {
                //ZEND_STR_INTERN_DUP(info->name, info->name_length)
                info->name = apc_new_interned_string(info->name, info->name_length TSRMLS_CC);
}

If I use ZEND_STR_INTERN_DUP then the reflection method works but otherwise it fails. It's starting to fail from revision 324142 while it works in 324141.
 [2012-04-12 08:56 UTC] peacech at gmail dot com
This also works

if (ce->name) {
            //ZEND_STR_INTERN_DUP(ce->name, ce->name_length)
            ce->name = apc_new_interned_string(ce->name, ce->name_length+1 TSRMLS_CC);
            //ce->name = apc_new_interned_string(ce->name, ce->name_length TSRMLS_CC);
		}

        q = ce->properties_info.pListHead;
        while (q) {
            zend_property_info *info = (zend_property_info*)(q->pData);

            if (q->nKeyLength) {
                q->arKey = apc_new_interned_string(q->arKey, q->nKeyLength TSRMLS_CC);
            }

            if (info->name) {
                //ZEND_STR_INTERN_DUP(info->name, info->name_length)
                info->name = apc_new_interned_string(info->name, info->name_length+1 TSRMLS_CC);
                //info->name = apc_new_interned_string(info->name, info->name_length TSRMLS_CC);
            }

            q = q->pListNext;
        }
 [2012-07-17 10:18 UTC] ab@php.net
Thank you for your bug report. This issue has already been fixed
in the latest released version of PHP, which you can download at 
http://www.php.net/downloads.php

This is fixed in APC 3.1.10 for sure.
 [2012-07-17 10:18 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sun Apr 20 15:01:54 2014 UTC