|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-05-19 20:06 UTC] bhines at alumni dot ucsd dot edu
Description:
------------
php crashes if i connect to a closed ODBC pconnect. I know this is very bad code below, but php should probably not crash.
I reproed this with both 5.1.4 and today's 5.2 snapshot.
Reproduce code:
---------------
<?php
$mydb = NULL;
printPage();
function pdb_Connect()
{
global $mydb;
if($mydb == NULL)
{ /* To repro, you need to supply a valid DSN and user/pass here. Only crashes with pconnect here, not connect. */
$mydb = odbc_pconnect("YourDSN", "YourUser", "YourPass", SQL_CUR_USE_ODBC) or die(odbc_errormsg() );
}
return $mydb;
}
function printPage()
{
$mydb = pdb_Connect();
odbc_close($mydb);
print "Possibly Crashing now... ";
$results = odbc_exec($mydb, 'SELECT * FROM _PDB_Access');
}
?>
Expected result:
----------------
With warnings on, i'd expect something like:
Possibly Crashing now...
Warning: odbc_exec(): supplied argument is not a valid ODBC-Link resource in d:\inetpub\wwwroot\include\test\testcrash.php on line 20
Actual result:
--------------
Possibly Crashing now... PHP has encountered an Access Violation at 7C901010
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 04 23:00:01 2025 UTC |
Hi There is a simple work-around to make this script work - there is a problem with the fact that you declared the $mydb var global in one function but not the other. You can change the printPage() function to solve this issue. function printPage() { global $mydb; $mydb = pdb_Connect(); odbc_close($mydb); print "Possibly Crashing now... "; $results = odbc_exec($mydb, 'SELECT * FROM _PDB_Access'); }