php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35592 ODBC/DB2 driver crashes Apache on bad request
Submitted: 2005-12-08 00:05 UTC Modified: 2005-12-29 01:00 UTC
Votes:5
Avg. Score:4.8 ± 0.4
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:4 (100.0%)
From: mrethers at ebcubes dot com Assigned: wez (profile)
Status: No Feedback Package: PDO related
PHP Version: 5.1.1 OS: Windows XP SP2
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2005-12-08 00:05 UTC] mrethers at ebcubes dot com
Description:
------------
I'm using a db2 database with pdo:odbc and some bad queries would crash Apache. It's a major problem for debugging as I have to verify all the requests with a SQL command line tool.

Reproduce code:
---------------
SELECT * FROM TableA, TableB;

>> where TableA and TableB are in schema SCHEMA_1

The acutal query should be:

SELECT * FROM SCHEMA_1.TableA, SCHEMA_2.TableB;

Expected result:
----------------
SQL Exception from error thrown by the database


Actual result:
--------------
Apache crashes

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-08 11:26 UTC] tony2001@php.net
Please try using this CVS snapshot:

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


 [2005-12-08 17:09 UTC] mrethers at ebcubes dot com
I tried downloading the last snapshot for win32 but it now completely crashes my applcation. The XML DOM extension seems to be the issue

# Suspected Code
$doc = new DOMDocument;
$doc->Load(CONFIG_PATH);
if (!$doc->validate()) {
    throw new Exception("Mapping file is not valid");
}

Also I still have the DB2/ODBC problem :

# Problematic code example
try {
  $dbh = new PDO('odbc:TEST', 'user', 'password');
} catch (Exception $e) {
  echo "Failed: " . $e->getMessage();
}
$stmt = $dbh->query("SELECT * FROM Table1");
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$rs = $stmt->fetchAll();
echo count($rs) . " : ";

when correct query should be SELECT * FROM SCHEMA1.Table1
crashes Apache before $stmt->setFetchMode(PDO::FETCH_ASSOC);
 [2005-12-08 22:42 UTC] tony2001@php.net
Assigned to the maintainer.
 [2005-12-09 05:21 UTC] wez@php.net
Can you reproduce this with mssql or access?
 [2005-12-12 22:49 UTC] dbs@php.net
Confirmed the problem here with php5-win32-200512111930.zip from snaps.php.net, as well as php-5.1.1 Windows binary from php.net, running PHP CLI (taking Apache out of the equation).

This is with DB2 V8 FixPak 10, using the DB2 sample database cataloged as a SYSTEM ODBC data source.

Windows XP SP1 with all current (non SP2) fixes.

My slight variation: SELECT * FROM EMPLOYEE works as expected, but SELECT * FROM FOO.EMPLOYEE (non-existent schema) causes Windows to pop up one of those handy little "CLI has encountered a problem and needs to close. Would you like to send this error report to microsoft?" dialogs.

I would expect an error message like the following:

SQL0204N  "FOO.EMPLOYEE" is an undefined name.  SQLSTATE=42704
 [2005-12-14 06:03 UTC] wez@php.net
I couldn't reproduce the issue, but by working with Dan, did manage to get a couple of backtraces that highlighted some code that might cause something like this to happen.

Please try the next snapshot dated after this message to see if that nailed it.
 [2005-12-14 15:35 UTC] dbs@php.net
Hmm. Still getting a crash and the same backtraces with snapshot built On: Dec 14, 2005 11:30 GMT (SQLBindParameter with pdo_odbc.connection_pooling=off, SQLDriverConnectW with pdo_odbc.connection_pooling=strict or relaxed).

mrethers, what version of odbc32.dll is installed on your system?

Dan's system(crashes):  3.520.9042.0
Wez's system(no crash): 3.525.1117.0
 [2005-12-21 20:29 UTC] dbs@php.net
Additional test:

On a system with Windows XP SP2, DB2 Run-Time Client Lite Version 8 FixPak 10, odbc32.dll version 3.525.1117.0, connecting to a DB2 database, I still get a crash. So much for the odbc32.dll theory... Here's the backtrace using php-5.1-win32-200512180730:

0:000> kv
ChildEBP RetAddr  Args to Child
WARNING: Stack unwind information not available. Following frames may be wrong.
0012f8c8 74327f94 00000000 10008ec0 00abce70 ODBC32!MpHeapAlloc+0x435
0012f8e8 7434350b 003b1db0 00000001 000003ee ODBC32!SQLDisconnect+0x147
*** WARNING: Unable to verify checksum for C:\Programs\php5.1-snap\ext\php_pdo_odbc.dll
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Programs\php5.1-snap\ext\php_pdo_odbc.dll
 -
0012f904 00391c75 00000003 74350000 1009a470 ODBC32!SQLFreeHandle+0x1f3
00000000 00000000 00000000 00000000 00000000 php_pdo_odbc+0x1c75
0:000>

This is using a modified version of mrethers' test case. I thought it was bad form to access $stmt->fetchAll() when $stmt was not a valid object, so simplified the test case to this:

<?php
# Problematic code example
try {
  $dbh = new PDO('odbc:SAM', 'test', 'test');
} catch (Exception $e) {
  echo "Failed: " . $e->getMessage();
}
$stmt = $dbh->query("SELECT * FROM foo.Employee");
?>

(where foo.Employee is a table that does not exist in the target database... same test works fine if I point to a table that does exist in the database).
 [2005-12-29 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".
 [2007-08-29 02:29 UTC] sumguyovrthar at gmail dot com
I still have the same problem with PHP 5.2.3, and not only with PDO but also with the ODBC extension (odbc_connect(), etc).

I have an older update of Win XP: SP1, and my odbc32.dll version is 3.520.90.42.0.

Apache's logs say a child process exited with status 3221225477 when this happens.

When Apache crashes and I don't stop my browser from loading, once Apache picks up again it continues doing what it was doing and the rest of my PHP script runs as it should.

This code:

<?php
$db = odbc_pconnect( 'rentmasterdb', 'George Washington', '' );
print_r( odbc_fetch_array( odbc_tables( $db ) ) );
?>

Crashes Apache at odbc_pconnect(), then yields the first returned row:

Array
(
    [TABLE_CAT] => C:\PROGRAM FILES\RENTMASTER INC\RENTMASTER\DATA
    [TABLE_SCHEM] => 
    [TABLE_NAME] => addresses
    [TABLE_TYPE] => TABLE
    [REMARKS] => 
)

So it connects OK after getting by the Microsoft error reporting dialogs and restarting the child process. I thought using a persistent connection might only crash it on the first run and then not crash when it picks up the connection later, but I'm using the PHP CGI binary so I guess that's why it didn't work.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 22:01:26 2024 UTC