php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38520 vardump($einfo = $pdo->errorInfo()) causes php to crash
Submitted: 2006-08-20 14:19 UTC Modified: 2006-08-20 18:04 UTC
From: selecter at gmail dot com Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5.1.4 OS: Linux Gentoo 2006.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: selecter at gmail dot com
New email:
PHP Version: OS:

 

 [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)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-20 14:21 UTC] selecter at gmail dot com
I also run x86_64 if it helps
 [2006-08-20 14:34 UTC] selecter at gmail dot com
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);

        }
?>
 [2006-08-20 14:40 UTC] selecter at gmail dot com
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';

        }
?>
 [2006-08-20 14:42 UTC] selecter at gmail dot com
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.
 [2006-08-20 14:45 UTC] pajoye@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-08-20 17:00 UTC] selecter at gmail dot com
Worked fine on latest snapshot.
 [2006-08-20 18:04 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 22:01:29 2024 UTC