|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-05-25 00:53 UTC] barry at hpfm dot com dot au
Description:
------------
I am developing an application that runs php on Rh9.0,Apache1.3 that accesses data residing on a Windows SBS server running SQLSERVER.
I am getting huge apache error_log files (see attached sample) because of a memory leak in msssql.c.
The application runs quite slowly and really hammers the apache server.
The application is using PEAR DB, DBO.
Occassionally the $dbo->find() will not return anything at all.
Reproduce code:
---------------
<?php
require_once "config.php";
require_once "DataObjects/Person.php";
require_once "DataObjects/Members.php";
$person = new DataObject_Person;
$member = new DataObject_Members;
echo "Starting DB Tests: find all CPl members<br>";
$member->debugLevel(0);
echo "Issue find request<br>";
$transfers=$member->find();
echo $transfers." CPL folk to translate<br>";
while ( ( $member->fetch() ) )
{
echo "<pre>";
var_dump($member->toArray());
echo "</pre>";
}
?>
Actual result:
--------------
---------------------------------------
[Tue May 25 08:47:49 2004] Script: '/www/sites/slsa/SLSA_Members/include/DBTes
ts01.php'
---------------------------------------
/downloads/php4.3/php4.3.5/php-4.3.5/ext/mssql/php_mssql.c(191) : Block 0x083839
00 status:
/downloads/php4.3/php4.3.5/php-4.3.5/Zend/zend_variables.c(44) : Actual location
(location was relayed)
Beginning: OK (allocated on /downloads/php4.3/php4.3.5/php-4.3.5/ext/mssql/
php_mssql.c:847, 19 bytes)
End: Overflown (magic=0x2A8FCC00 instead of 0x2A8FCC84)
1 byte(s) overflown
---------------------------------------
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 10:00:01 2025 UTC |
We are experiencing a similar crash, when values in decimal or numeric columns are larger than certain values. Reproduced on MS SQL 2000 on Windows 2000 Server, with Apache 1.3.27 as webserver or CLI php exe on Win XP. Create table with data: CREATE TABLE [dbo].[test] ( [test_decimal] [decimal](23, 6) NULL , [test_numeric] [numeric](23, 6) NULL ) ON [PRIMARY] GO INSERT INTO test (test_decimal, test_numeric) VALUES (99999999999999999.999999, 99999999999999999.999999) GO Run following PHP script: <?php $conn = mssql_connect('yourserver', 'you', 'password'); echo "Connection OK<br />\n"; mssql_select_db('yourdatabase', $conn); echo "DB selected OK<br />\n"; $result = mssql_query('select test_decimal, test_numeric from test', $conn); echo "Query OK<br />\n"; $array[] = mssql_fetch_field($result, 0); $array[] = mssql_field_name($result, 0); $array[] = mssql_field_type($result, 0); $array[] = mssql_field_length($result, 0); $array[] = mssql_fetch_assoc($result); echo "Results fetched OK<br />\n"; echo '<pre>'; var_export($array); echo '</pre>'; mssql_close($conn); ?> I have solved the issue with the following diff of changes to php_mssql.c: 841a842 > case SQLDECIMAL: 850,852c851,866 < if (column_type == SQLDATETIM4) res_length += 14; < if (column_type == SQLDATETIME) res_length += 10; < --- > switch (column_type) { > case SQLDATETIM4 : > res_length += 14; > break; > case SQLDATETIME : > res_length += 10; > break; > case SQLMONEY : > case SQLMONEY4 : > case SQLMONEYN : > case SQLDECIMAL : > case SQLNUMERIC : > res_length += 5; > break; > } > 919a934,935 > case SQLDECIMAL : > case SQLNUMERIC : The buffer res_buf was beeing allocated to small (20 for above columns, when 24 is required) Hope that this helps, as it is critical for us!