From: dangerousdave86 at hotmail dot com
Operating system: Windows XP Pro SP1
PHP version: 5.1.0b3
PHP Bug Type: Reproducible crash
Bug description: Apache2 crashes when SQLite PDO returns 0 Rows
Description:
------------
When I query an SQLite database through PHP5.1.0b3's PDO functions on
Apache2.0.54, everything appears fine. This is until I query the database
with a SELECT that matches no rows. What I mean by this is that when I do
a SELECT with criteria I know will match DB rows, it returns the rows
nicely. When I query the DB using a criteria I know will not match any
rows in the database, PHP stops at the $PDO->Query call and Apache
crashes.
Apache Crash data: Faulting application Apache.exe, version 2.0.54.0,
faulting module php5ts.dll, version 5.1.0.0, fault address 0x00008034.
I have not attempted to reproduce this bug outside of my current project,
if this would help I can do it. But to reproduce I think all is necersary
is to run a select on an SQLite Database that will not return any rows.
I know that I have not coded this problem myself, as when I swap to the
MySQL PDO driver, there are no issues whatsoever.
The current goal of my PHP project is to migrate to SQLite from MySQL, and
this bug is standing right in the way of doing so. So until it is fixed I
am kind of stuck.
Any feedback would be appreciated, I'll do my best to help anyone who
tries to find the problem.
Reproduce code:
---------------
<?php
// Reproduce SQLite bug
// Assumes file permissions are good
if (file_exists ('database1.db')) unlink ('database1.db');
// Create the new PDO object
$PDO = new PDO ('sqlite:database1.db');
// Fill the database with test data
$PDO->query ('CREATE TABLE "test_table" ( "test_index" INTEGER NOT NULL
PRIMARY KEY AUTOINCREMENT, "test_data" TEXT NOT NULL default "")');
for ($i = 1; $i <= 10; $i++) $PDO->query ('INSERT INTO test_table
("test_data") VALUES ("value '.$i.'")');
// Possible die here to stop and check the database worked using
SQLite3.exe from sqlite.org
// die;
$query_match = 'SELECT * FROM test_table WHERE test_data = "value 5"';
$query_nomatch = 'SELECT * FROM test_table WHERE test_data = "value
100"';
// Run working query
$PDOStatement = $PDO->query ($query_match);
$results = $PDOStatement->fetchAll (PDO_FETCH_ASSOC);
file_put_contents ('debug.txt',print_r ($results, TRUE), FILE_APPEND);
// Run non-working query
$PDOStatement = $PDO->query ($query_nomatch);
// The program will never get to here
$results = $PDOStatement->fetchAll (PDO_FETCH_ASSOC);
file_put_contents ('debug.txt',print_r ($results, TRUE), FILE_APPEND);
?>
Expected result:
----------------
I would expect this script to just execute, outputing a blank page and a
text file with some information in it.
Actual result:
--------------
Apache crashes
--
Edit bug report at http://bugs.php.net/?id=33844&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33844&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33844&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33844&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33844&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33844&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33844&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33844&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33844&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33844&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33844&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33844&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33844&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33844&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33844&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33844&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33844&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33844&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33844&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33844&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33844&r=mysqlcfg