|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-08-21 12:10 UTC] wolff at 21st dot de
Description: ------------ This is with APC 3.0.10 - I'm storing a prepared statement object in a static object variable to act as a statement cache. When I do that, PHP seems to make a clean exit, but Apache segfaults and just displays a blank page. This seems not to occur on the first request after a fresh Apache restart, though - but on all subsequent ones. Additional discussion of the bug can be found here: http://blog.wolff-hamburg.de/index.php?url=archives/9-UPDATE-Bug-found-kinda.html ...only I came to the conclusion that it was APC's wrong-doing after I already submitted the blog post. Bug *may* be somehow related to this one: http://pecl.php.net/bugs/bug.php?id=8324 ...but for me it only happens when storing prepared statements in static variables. Reproduce code: --------------- class SegFault { static protected $cache = array(); public function execute() { $pdo = new PDO('mysql:host=localhost;dbname=mysql', 'root'); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $pdo->prepare('SELECT user FROM user WHERE host=:hostname'); self::$cache[] = $stmt; // this is the culprit, remove this line and all is well $bindings = array(':hostname' => 'localhost'); $stmt->execute($bindings); return $stmt; } } $crash = new SegFault(); echo "<p>Timestamp: ".time()."</p><pre>"; foreach($crash->execute() as $row) { print_r($row); } echo "</pre>"; Expected result: ---------------- A page should be served containing the current timestamp and a printout of all MySQL users for localhost. Actual result: -------------- Apache segfaults: [Mon Aug 21 17:40:58 2006] [notice] child pid 27755 exit signal Segmentation fault (11) Either disabling APC or commenting out the line "self:: $cache[] = $stmt;" will fix the problem. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 03 21:00:01 2026 UTC |
I just got the same error and created a test case $test = new test(); echo "hello world"; class test { public function __construct() { $dsn = 'mysql:host=localhost;dbname=mydb'; $dbh = new PDO($dsn,'foo','****'); $x = $dbh->prepare('SELECT * FROM table'); self::$cache = $x; // remove me } } deactivating apc didnt work. First request after apache restart works well, second request end up with a blank page. PHP Version 5.1.6-pl4-gentoo with (or without) APC 3.0.12p2