Re: Schroedinger's Bug - may require exorcism...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



What to do next?  I'd check to see if your page is being inadvertantly called twice (I've seen this happen when people used frames.. or like someone else mentioned, doing a double include() or sometimes redirecting back to itself via header())... anything that could possibly re-initiate the page, check into.

Failing that, do it old school...  just inserted die() statements to break execution at various points and see where the probably first starts occuring and focus in that area.  Crude but it works.  At least helps narrow down where the problem could be.

It doesn't do something silly like include() itself inside a conditional somewhere does it?

You might also echo/var_dump/print_r/whatever some of your key variables (especially input variables like $_GET/$_POST/etc and variables used in conditionals) and try to isolate what combination causes your problem.  Since it doesn't do it all the time, I'd guess you could have something like:

$x = 4;

if ($x > 1) {
  include('someinclude.inc');
}

if ($x < 5) {
  include('someinclude.inc');
}

Where 'someinclude.inc' contains your double declarations.


Next point... check your logic around your include()/require()s and such.  Maybe you have a condition where something is falling into multiple categories.


The logic puzzle is as much about writing good logic as untangling possibly flawed logic.

If all else fails, trace through your code by hand... interpret it in your head like the computer would.. like by line.. maybe you'll see where something is ambiguous and under certain conditions creates a fail.

Let us know what you find.. kind of curious myself.

-TG

= = = Original message = = =

So... I have this script (being called in a perfectly typical way by  
PHP 4.4.1 through mod_php in Apache 2.0.55) which sometimes runs  
perfectly, and sometimes chooses, totally haphazardly, to seemingly  
run itself twice, which of course causes it to die with a fatal error  
after it tries to redefine some functions.

As mysterious as that is, it turns out it must be something  
altogether more sinister. I tried putting die() at the end of the  
script, on the assumption that it was for some reason executing  
twice, yet behold: the problem is still present, and the PHP error  
log still complains about constants and functions being redefined!  
The problem, I therefore thought, cannot be that the script is being  
run twice. (In retrospect, this was the most likely possibility,  
because the page doesn't actually output anything if it dies with  
this error.) So for debugging, I added a bit that logs one message to  
a file immediately before the die() at the end of the file, and a  
different message after the die(). The die() seems to be working  
normally, in that it only logs the first message...

But wait a second! WTF? If the PHP error log is to be believed, then  
the script should be dying with a fatal error before it even *gets*  
to that point in the script, isn't it?

And the greater WTF is the fact that, as I mentioned above, every  
time the page is requested, it unpredictably either does this or  
works flawlessly. Oh my. How do I even *begin* to debug something  
like this?

Thanks for any help.
-- Adam Atlas


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux