php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35837 Crash when using PDO::FETCH_LAZY
Submitted: 2005-12-29 11:56 UTC Modified: 2006-12-12 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: mfischer@php.net Assigned:
Status: No Feedback Package: PDO related
PHP Version: 5CVS-2005-12-29 (snap) OS: Windows
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: mfischer@php.net
New email:
PHP Version: OS:

 

 [2005-12-29 11:56 UTC] mfischer@php.net
Description:
------------
PHP crashes at the end of the script when I use PDO::FETCH_LAZY.

I've to say that from my testing (for some clever reason I started to use PDO::FETCH_LAZY right from the start and therefore have gone through many obscure crashes and exceptions) that I also saw the following problems with it:
* it seems to consume memory and never releases it. I've got exception thrown from the Microsoft Access Driver about running out of memory. When I stopped using PDO::FETCH_LAZY the exception was never thrown again.
* I got exception thrown about "invalid table ids" for now reasons which also went away when I stopped using PDO::FETCH_LAZY

I was working with an Access Database (mdb file) but never fetching big data but it were about 1500 SQL statements sent.

I've read report http://bugs.php.net/bug.php?id=35431 but I can confirm this for the current snapshot also.

Reproduce code:
---------------
$p = new PDO('odbc:driver={Microsoft Access Driver (*.mdb)};Dbq=beispieldatenbank.mdb');
$s = $p->query("SELECT COUNT(*) FROM ADDRESSES WHERE GUID = ''", PDO::FETCH_LAZY);
$s->fetch();


Expected result:
----------------
Script should not crash.

Actual result:
--------------
Script crashes and Windows prompts me with a dialog to send a report to M$

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-29 13:20 UTC] sniper@php.net
Assigned to the maintainer.
 [2006-03-22 23:23 UTC] exaton at free dot fr
PHP Version 5.1.3RC2-dev 2006-03-19 15:30
WinXP SP2, Apache2 2.0.55

More haywire behaviour when using FETCH_LAZY :

$SQL = new PDO('pgsql:host=localhost;port=5432;dbname=xxxxx', 'user', 'password');

$stmt = $SQL -> query('SELECT ident, descr FROM variables ORDER BY ident');

$stmt -> setFetchMode(PDO :: FETCH_LAZY);

foreach ($stmt as $row) {
  var_dump($row -> ident); (1) // existing column
  var_dump($row -> foo); (2) // non-existant column
}

$SQL = NULL;

The first (2) is garbage, and so are practically all following (1) and (2). At the next page load, Apache crashes. Apache crashes every two page loads in this fashion.

Comment out (1), leaving (2). The first output is NULL, followed by whole PDORows. Apache no longer crashes.

Add, in appropriate locations :

class MyPDOStatement extends PDOStatement { }

$SQL -> setAttribute(PDO :: ATTR_STATEMENT_CLASS, array('MyPDOStatement'));

(1) left commented out. The first (2) is bool(true), the following ones are whole PDORows again. Apache doesn't crash.

Replace those two additions with :

class MyPDOStatement extends PDOStatement {
  private function __construct() { }
}

$SQL -> setAttribute(PDO :: ATTR_STATEMENT_CLASS, array('MyPDOStatement', array()));

Then the first (2) is :

object(MyPDOStatement)#2 (1) {
  ["queryString"]=>
  string(49) "SELECT ident, descr FROM variables ORDER BY ident"
}

and the following are PDORows again. Apache still no longer crashes.

Have fun >.>
 [2006-12-04 03:20 UTC] iliaa@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

Does not appear to crash with latest CVS.
 [2006-12-12 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 17:01:29 2024 UTC