From: [EMAIL PROTECTED]
Operating system: Windows 2000 Server
PHP version: 4.2.3
PHP Bug Type: Reproducible crash
Bug description: PHP crashed when closing connection to MSSQL
NOTE: This situation will only happens on TRADITIONAL
CHINESE (Big5 code) environment.
I'm using PHP4.23 (Windows binary installer version),
TRADITINOAL CHINESE version of Windows 2000 Server with SP3
and TRADITINOAL CHINESE version of SQL Server 2000 with
SP2. The php_mssql.dll are extracted from PHP4.23 Windows
binary ZIP version. Do not have other extension,
ZendOptimizer not installed.
PHP crashed when closing connection to MSSQL under certain
conditions. The crashing signs are: IE will not close TCP/
IP connections (even on localhost,) and php.exe will not
stop. This problem also happens on at least three different
servers with different Service Packs.
This crashing situation happens when SELECT datetime/
smalldatetime format column. PHP will force-convert the
datetime format into CHINESE datetime format on TRADITIONAL
CHINESE version of Windows 2000 Server. For example:
mssql_query('SELECT GetDate()');
and the result will be:
2002 �Q�@�� 15 12:00�W��
You may not be able to see the Chinese words, the 6
characters behind '2002' are 'November' in Chinese, and the
4 characters behind '12:00' are 'AM' in Chinese.
After crash, the php.exe will stay in the task list for 10
minutes. Sometime it may consume 99% of CPU time. And the
SQL database will be locked, MSSQL Extension Manager may
forbid any task related to that database, like backup,
restore, optimize, or delete. The berserk php.exe process
can not be terminated by Windows task manager, IIS reboot
or shutdown MSSQL service. The only to get rid of it is to
wait or reboot server.
It took me lots of time to determine what's going on cause
this crashing only happens when these two condition are
matched:
Condition 1:
There are two or more datetime/smalldatetime columns appear
in one query. For example, if I have a table like this:
CREATE TABLE login_log_table (
sn INT IDENTITY(1,1) PRIMARY KEY,
loginname CHAR(10),
sessionid VARCHAR(32),
logintime SMALLDATETIME,
logouttime SMALLDATETIME
);
If I execute this query:
SELECT * FROM login_log_table WHERE loginname='richard';
PHP will crash. But this query:
SELECT
sn, sessionid, convert(char(16),logintime,21), convert
(char(16),logintime,21)
FROM login_log_table WHERE loginname='richard';
that will be OK.
Condition 2:
The first process will finish the query without any
problem, but the second process will crash.
I've one Mac G4 and 2 PCs, when I was debugging, I found
that connections from PCs have no problem, but connection
from Mac will crash. I don't know why until I add different
arguments at the end of URL on a PC and crashed. For
example:
select.php
<?
$conn = mssql_connect("127.0.0.1","sa","xxxx");
mssql_select_db('test_db',$conn)
$sql = "SELECT * FROM login_log_table loginname=
'richard'";
$res = mssql_query($sql);
$data = mssql_fetch_row($res);
print_r($data);
mssql_free_result($res);
mssql_close($conn);
?>
Suppose this code is placed on server at 192.168.1.100.
When I first call
http://192.168.1.100/select.php
that would be OK. Now I change the URL to:
http://192.168.1.100/select.php?abc=def
it will crash. As you can see, variable $abc is not used in
select.php. I tried register_globals = On/Off, same result.
I'm not Windows system engineer, but I guess there may be
some sort of connection cache between PHP and MSSQL, though
I did not use presistant connections in my code, and there
may be some other sort of process cache in IIS or PHP. For
the same connection HTTP header (URI,Agent,etc.) IIS or PHP
may be using the cached intermediate code and process ID to
recall the last MSSQL connection, which is also cached. Now
the datetime format may cause a problem that prevent MSSQL
from release the resource, as a result, the NEW process
query for the SAME record will be blocked. That's only my
guess.
I tried to modify the local-settings of Windows Server, and
mssql.datetimeconvert=off in php.ini, none would work. The
only way I can work around this problem is to avoid using
'SELECT *' syntex in my codes.
--
Edit bug report at http://bugs.php.net/?id=20439&edit=1
--
Try a CVS snapshot: http://bugs.php.net/fix.php?id=20439&r=trysnapshot
Fixed in CVS: http://bugs.php.net/fix.php?id=20439&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=20439&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=20439&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=20439&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=20439&r=support
Expected behavior: http://bugs.php.net/fix.php?id=20439&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=20439&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=20439&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=20439&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20439&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=20439&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=20439&r=isapi