php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33844 Apache2 crashes when SQLite PDO returns 0 Rows
Submitted: 2005-07-24 08:14 UTC Modified: 2005-07-24 09:59 UTC
From: dangerousdave86 at hotmail dot com Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 5.1.0b3 OS: Windows XP Pro SP1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dangerousdave86 at hotmail dot com
New email:
PHP Version: OS:

 

 [2005-07-24 08:14 UTC] dangerousdave86 at hotmail dot com
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-24 08:16 UTC] dangerousdave86 at hotmail dot com
Decided to create reproduce code in the end.
 [2005-07-24 09:42 UTC] dangerousdave86 at hotmail dot com
I have worked out a work around, so that I can continue developing with my current setup. Doing a SELECT COUNT (*) WHERE [criteria], will return 0 for SELECTs that would normaly return 0 rows and crash Apache2.

I may also test to see if this happens with Apache1, but for now I can continue development.
 [2005-07-24 09:59 UTC] dangerousdave86 at hotmail dot com
I upgraded my PHP with php5-win32-latest.zip and the problems have disapeared, keep up the good work, PHP5.1 will be done in no time. Sorry for the useless post.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 18:01:29 2024 UTC