[I'm afraid of getting flamed for how bad the code was in the example
in my first email.  I've replaced the example in this email.  The
rest is the same.  The example still isn't great, but it's better
than before.]

It feels like there is a bug in php somewhere.  I'm trying to debug 
this myself before filing a report and am in over my head.  The
short version of my question may be "How do I set a watch on
SG(sapi_headers).http_response_code in the gdb?"
I think I need to debug it myself because I haven't been able to 
reproduce it in a simple case.  The following simple case works:

<?php
function f($processed_string) {
        // eval returns false on failure (e.g. division by 0)
        $eval_result = @eval('$retval=('.$processed_string.');');
        if ($eval_result === false) {
            return 'Unknown';
        }
        return $retval;
}
print f('0+5')."\n";  // Good
print f('0(6)')."\n"; // Bad, but shouldn't lead to code 500
print f('0+')."\n";   // Bad, but shouldn't lead to code 500
?>

That example doesn't return code 500.  But my big ugly application
does.  I get a response code 500 if the eval is given poorly formed 
code.  The exact same request is processed happily if the eval of 
poorly formed code is commented out or replaced with an eval of 
good code.  The poorly formed code can be as simple as in the above
example.

I've rebuilt apache 1.3.37 so that I can use gdb.  (I'm using
php 5.4.3)  After about 10 hours I've only gotten as far as 
learning that r->status becomes 500 while the headers are being 
prepared at the time of the print.  That happens in mod_php5.c
on line 231: r->status = SG(sapi_headers).http_response_code;
I guess my next step is to find out when 
SG(sapi_headers).http_response_code became 500.  Given that
the problem appears/goes away based on whether the eval is
given bad code, I'm guessing the response_code is being affected
by the eval(), but I'd like to be more concrete about it and
maybe even be able to come up with a fix (or at least a good
enough description that someone who really understands internals
can come up with a fix without much trouble).

Perhaps I've completely misunderstood something about php and
should be directing this to a different list.  My confidence
is high that a bad eval() shouldn't ruin the page, so I'm here
looking for debugging advice.  If I'm in the wrong place, I
apologize.

Thanks for any pointers!

- Todd



-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to