#27380 [Opn->Fbk]: Segmentation fault executing do..while() loops inside block containers

From: Date: Tue, 24 Feb 2004 16:32:06 +0000
Subject: #27380 [Opn->Fbk]: Segmentation fault executing do..while() loops inside block containers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-55462@lists.php.net to get a copy of this message
ID: 27380 Updated by: derick@php.net Reported By: josh at hostyour dot info -Status: Open +Status: Feedback Bug Type: Reproducible crash Operating System: RH7.3 PHP Version: 4.3.4 New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try avoid embedding huge scripts into the report. Can't reproduce this with only a part of a script. Previous Comments: ------------------------------------------------------------------------ [2004-02-24 11:26:11] josh at hostyour dot info Description: ------------ If I have a function that has a do..while(); construction in it, inside a block container { }, PHP will segfault on exiting the block container UNLESS I have a statement in between the end of the while (); and the closing brace of the block. This does NOT happen in "global" execution. A do..while() loop that lives outside any function's scope works just fine; I have several other do..while() constructs outside of functions that work with no problems. The segfault seems to only happen when the do..while(); is inside a function AND inside a block container (in this case, belonging to an if statement). Any ideas? Reproduce code: --------------- function announce() { global $totalRows_announce, $row_announce, $announce, $srs; $ann = ""; if ($totalRows_announce > 0) { do { $author = mysql_result(mysql_query("SELECT nick FROM players WHERE id='".$row_announce['author']."'", $srs), 0, "nick") or die(mysql_error()); $msg_body = stripslashes(implode("<br>",explode("\n",$row_announce['msg_body']))); $ann .= textBlock(textBlock($row_announce['subject'], "", "anntitle") . br() . textBlock("Posted by:".$author." | On: ".$row_announce['posted_date'], "", "annhead") . br() . textBlock($msg_body, "", "annbody"), "", (($row_announce['urgent'] == 1) ? "redrow" : ((($ctr++) % 2) ? "lightrow" : "darkrow"))) . br(); } while ($row_announce = mysql_fetch_assoc($announce)); // Segfault happens HERE } else { $ann = textBlock("No Announcements", "", "loginerr"); } return $ann; } Expected result: ---------------- The code, as intended, returns a string of HTML code to the calling function. Actual result: -------------- The code immediately segfaults when it encounters the closing brace of the do..while() loop's block container UNLESS there is an intervening statement. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=27380&edit=1

« previous php.bugs (#55462) next »