|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-07-31 20:43 UTC] dragonzap1 at aol dot com
Script:
<?php
$string = 'string';
echo 'There is ';
switch($string) {
default:
echo 'NOT ';
break;
}
echo 'a problem.';
someFunction(NULL);
$ec = new EmptyClass();
$somevar = $ec->someMethod(NULL);
$ec->someMethod();
$ec->someMethod();
someFunction();
function someFunction($var = '') {
}
class EmptyClass {
function someMethod($data = '') {
}
}
?>
Compile flags:
--with-mysql=/usr/local/mysql
--with-apache=/usr/local/src/apache
--with-gd=/usr/local/src/gd
--with-jpeg-dir=/usr/local/src/jpeg
--with-xml
--with-zlib
--enable-versioning
Problem:
For some reason, this program doesn't always print out "There is NOT a problem." This problem seems to be VERY specific, and doesn't always happen (but if the page is reloaded a bunch of times, it should eventually say 'There is a problem.' and on rare occasions may crash altogether) It will start working as expected, however, if any of the calls to someFunction() or someMethod() are removed, or the arguments are removed or changed to non-NULL values. Adding any other case to the case statement (whether you keep the 'default' or not) will make it function properly as well.
The someFunction/EmptyClass/someMethod definitions can be removed while keeping this odd behavior intact, as well as the "$ec = new EmptyClass()", and then adding an "exit;" statement below the "echo 'a problem.';" line but I wanted to try to keep it mostly 'legal' PHP.
I know that most people aren't going to do a switch() statement with just a default case (it could happen as a placeholder in the middle of developing something, though, which is how I ran into it), but it may be indicative of a larger problem.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 16:00:01 2025 UTC |
Definitely something strange going on with this one. The following code works correctly on the first iteration, then incorrectly, and will throw a segfault after about 6-7 reloads. Both WinNT and Linux platforms. <?php switch("1"){ default: echo 'NOT '; break; } echo 'a problem.'; exit; someFunction(NULL); $ec = new EmptyClass(); $ec->someOtherMethod(); $somevar = $ec->someMethod(NULL); ?> Comment out any of the last four lines, and the code functions as expected. Add a case "0": statement and the code functions correctly. Any ideas anyone? (Yes, I realize the code is not realistic, but it does indicate some error in the parsing of it.)