Bug #68698 [Fbk->NoF]: Fatal error cannot redeclare [class not being redeclared]

From: Date: Sun, 18 Jan 2015 04:22:29 +0000
Subject: Bug #68698 [Fbk->NoF]: Fatal error cannot redeclare [class not being redeclared]
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190030@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=68698&edit=1

 ID:               68698
 Updated by:       php-bugs@lists.php.net
 Reported by:      pegasus at vaultwiki dot org
 Summary:          Fatal error cannot redeclare [class not being
                   redeclared]
-Status:           Feedback
+Status:           No Feedback
 Type:             Bug
 Package:          Scripting Engine problem
 Operating System: Centos 6 64-bit
 PHP Version:      5.6Git-2014-12-30 (Git)
 Private report:   N

 New Comment:

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.


Previous Comments:
------------------------------------------------------------------------
[2015-01-14 20:04:13] pegasus at vaultwiki dot org

I do not get this error consistently. 90% of the time I get this bug instead: https://bugs.php.net/bug.php?id=68453
The infinite loop caused by the bucket list change back in November. It occurs whether PHP has any
active extensions or not, and only in no-debug builds.

Thus reducing this issue to a simple test script is difficult. I have only experienced this so far
with one 3 MB PHP library that has a proprietary EULA, so it cannot be posted here. Similarly
designed test libraries work as expected.

In a test directory, I almost had success reducing the original library to 4 files that would
reproduce the fatal error. Then I made one change too many and the script executed successfully.
After reversing all of the changes such that the files match the originals I am unable to reproduce
the problem in my test directory.

Due to this I assumed it was limited to a specific directory structure or to a symlinked directory
structure, so I tried a separate installation of the library in a different part of the server, but
that infinitely looped.

I tried pointing the working test script to the original library and directory structure: the test
script completes successfully; the original script still does not.

Opcache is disabled, so any caching on a directory-basis should not occur. Even so, I have to
restart PHP-FPM after an infinite loop occurs because no other scripts will run, and my
understanding is that restarting the process would clear the opcache.

By any chance does PHP store names of classes internally in a hashed form? If so, is it possible I
may be experiencing a hash collision?

Since the issue is not consistent from one script to the next, is there some other cache other than
the opcache that I might have to clear manually?

------------------------------------------------------------------------
[2015-01-09 07:26:15] krakjoe@php.net

We don't have enough information to investigate the problem, please provide reproducing code.

------------------------------------------------------------------------
[2014-12-30 17:01:49] pegasus at vaultwiki dot org

After looking at the classes being declared by the autoloader where this occurs, it seems that the
[class_already_declared] was the last class newly instantiated before attempting to load this
[file_that_declares_a_different_class].

It also appears to be the second file that uses require_once to import a specific separate abstract
class, with the error-named file containing a class that extends from this abstract class.

This appears to be the first time that this situation occurs during the execution, so perhaps
require_once is not working properly, and the error message is incorrectly using the name of the
last instantiated class during execution, rather than the class being loaded. Even so, there is no
redeclaration occurring here.

However, I was unable to recreate this scenario using a test script that imported 2 extended classes
from the same abstract. The test script completes successfully, so there may be something else
contributing to the problem in the background of my main script such as out-of-sync memory or
hashes.

------------------------------------------------------------------------
[2014-12-30 16:28:36] pegasus at vaultwiki dot org

Description:
------------
In the process of trying to debug this issue on my end: https://bugs.php.net/bug.php?id=68453
I want to note that other bug was never resolved by the PHP team. I provided as much feedback as I
could with the minimal suggestions that were made, but the bug was closed as if I never did. The
change in bucket order mentioned in the report -still- results in an infinite loop in scripts using
PHP master when some objects recursively call instances of themselves (it seems that a method's
static variables might not be available on a second pass until the first call of the containing
method that should have already created the static has completed). If someone can reopen the issue
and look into it again, it would be appreciated.

Now, in the process of trying to debug that issue without any help from the PHP team, I discovered
that PHP was also throwing a fatal error if the recursion was bypassed:

Fatal error: Cannot redeclare class [class_already_declared] in
[file_that_doesnt_declare_that_class_at_all] on line 0

As I've noted in the message itself, the class HAS been declared already. However, the error
message says that a specific file is trying to redeclare it. The file claimed does not even include
the name of the class in so much as a string, and does not include any files that do either. The
fact that the error gives "line 0" in the "problematic" file is also not useful
information from a development standpoint.

This error is reproducible and always states that the same class is trying to re-declare from that
same file. It does not matter whether opcache is disabled or enabled.

This error does NOT occur in PHP 5.6.4.



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



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


Thread (17 messages)

« previous php.bugs (#190030) next »