|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-08-20 14:19 UTC] selecter at gmail dot com
Description:
------------
By method of trial and error I've found the lines of code which cause php process to crash.
It seems that PDO object's method returns kind of corrupted variable. It might be related to memory issue.
I tryed to run apache2 -X inside gdb, but after that my php files weren't processed by php so I could see only the code...
Reproduce code:
---------------
It's hard to paste here some lines that can cause crashing... I'll show some:
public function save($username, $prefs){
$st = $this->db->prepare("UPDATE preferences SET show_email=?, show_smiles=?, timezone_offset=?, messages_on_page=? WHERE uid=?");
$st->bindParam(1, $prefs['show_email'], PDO::PARAM_BOOL);
$st->bindParam(2, $prefs['show_smiles'], PDO::PARAM_BOOL);
$st->bindParam(3, $prefs['timezone_offset'], PDO::PARAM_INT);
$st->bindParam(4, $prefs['messages_on_page'], PDO::PARAM_INT);
$st->bindParam(5, Users::getUserId($this->db, $username), PDO::PARAM_INT);
if(($num=$st->execute()) === FALSE){
SQL::errorHandler($this->db);
}else{
$this->session->cacheUserPrefs($prefs);
}
}
So... SQL::errorHandler($this->db); passes pdo object to another method:
public static function errorHandler($ptr){
$einfo = $ptr->errorInfo();
$einfo = $ptr->errorCode.': '.$einfo[2];
?><pre><?php
debug_print_backtrace();
?></pre><?php
vardump($einfo); //This causes a crash
trigger_error($einfo, E_USER_ERROR); //And this as well if we comment the upper line
}
Actual result:
--------------
[Sun Aug 20 17:15:48 2006] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec2)
[Sun Aug 20 17:15:49 2006] [notice] Digest: generating secret for digest authentication ...
[Sun Aug 20 17:15:49 2006] [notice] Digest: done
PHP Warning: PHP Startup: zip: Unable to initialize module\nModule compiled with module API=20050922, debug=0, thread-safety=0\nPHP compiled with module API=20050922, debug=1, thread-safety=0\nThese options need to match\n in Unknown on line 0
[Sun Aug 20 17:15:49 2006] [warn] pid file /var/run/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Sun Aug 20 17:15:49 2006] [notice] Apache configured -- resuming normal operations
[Sun Aug 20 17:16:07 2006] [notice] child pid 24211 exit signal Segmentation fault (11)
[Sun Aug 20 17:16:08 2006] [notice] child pid 24212 exit signal Segmentation fault (11)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 21:00:01 2025 UTC |
Here's the code that crashes: <?php try{ $dsn = 'mysql:host=localhost;dbname=test'; $db = new PDO($dsn, 'root', 'pass', array(PDO_ATTR_PERSISTENT => 1)); }catch(PDOException $e){ trigger_error($e->getMessage(), E_USER_ERROR); } $prefs = array( 'show_email' => 0, 'show_smiles' => 1, 'timezone_offset' => 0, 'messages_on_page' => 5 ); $st = $db->prepare("UPDATE preferences SET show_email=?, show_smiles=?, timezone_offset=?, messages_on_page=? WHERE uid=?"); $st->bindParam(1, $prefs['show_email'], PDO::PARAM_BOOL); $st->bindParam(2, $prefs['show_smiles'], PDO::PARAM_BOOL); $st->bindParam(3, $prefs['timezone_offset'], PDO::PARAM_INT); $st->bindParam(4, $prefs['messages_on_page'], PDO::PARAM_INT); $st->bindParam(5, 6, PDO::PARAM_INT); if(($num=$st->execute()) === FALSE){ $einfo = $ptr->errorInfo(); $einfo = $ptr->errorCode.': '.$einfo[2]; ?><pre><?php debug_print_backtrace(); ?></pre><?php trigger_error($einfo, E_USER_ERROR); }else{ $this->session->cacheUserPrefs($prefs); } ?>Sorry... This is more likely you want: <?php try{ $dsn = 'mysql:host=localhost;dbname=test'; $db = new PDO($dsn, 'root', 'pass'); }catch(PDOException $e){ trigger_error($e->getMessage(), E_USER_ERROR); } $prefs = array( 'show_email' => 0, 'show_smiles' => 1, 'timezone_offset' => 0, 'messages_on_page' => 5 ); $st = $db->prepare("UPDATE preferences SET show_email=?, show_smiles=?, timezone_offset=?, messages_on_page=? WHERE uid=?"); $st->bindParam(1, $prefs['show_email'], PDO::PARAM_BOOL); $st->bindParam(2, $prefs['show_smiles'], PDO::PARAM_BOOL); $st->bindParam(3, $prefs['timezone_offset'], PDO::PARAM_INT); $st->bindParam(4, $prefs['messages_on_page'], PDO::PARAM_INT); $st->bindParam(5, 6, PDO::PARAM_INT); if(($num=$st->execute()) === FALSE){ $einfo = $db->errorInfo(); $einfo = $db->errorCode.': '.$einfo[2]; ?><pre><?php debug_print_backtrace(); ?></pre><?php trigger_error($einfo, E_USER_ERROR); }else{ echo 'ok'; } ?>No crash if to delete bindParam lines and pass $prefs to execute() if(($num=$st->execute($prefs)) === FALSE){ But: "Fatal error: : in /var/www/localhost/htdocs/crash.php on line 23" which gives me no idea what was wrong in my query.