From: macuyiko at gmail dot com
Operating system: Linux (64bit)
PHP version: 5.2.3
PHP Bug Type: ODBC related
Bug description: zend_mm_heap corrupted error when freeing resultset with
Intersystems' Cache
Description:
------------
Using Intersystems' Cache 64 bit ODBC driver (libcacheodbc.so) with
unixODBC causes PHP 5.2.3 to crash. (I never had a problem with the 32 bit
driver.) Also, using another ODBC tool, like isql, works fine.
I have managed to track down this problem in PHP's source code, in
php_odbc.c, in the function PHP_FUNCTION(odbc_free_result), there are the
following lines:
//...start fragment...
ZEND_FETCH_RESOURCE(result, odbc_result *, pv_res, -1, "ODBC result",
le_result);
if (result->values) {
for (i = 0; i < result->numcols; i++) {
if (result->values[i].value) {
efree(result->values[i].value);
}
}
efree(result->values);
result->values = NULL;
}
//...end fragment...
Commenting out the line:
efree(result->values);
causes PHP to Segfault.
Commenting out the line:
efree(result->values[i].value);
still gives the zend_mm_heap corrupted error.
When I comment out both lines, the problem disappears. But I fear that
this might not be good practice.
So what could be causing this problem? It is only with the 64 bit
driver/PHP/Linux that this error occurs. Using the 32 bit driver works.
Other databases' ODBC drivers work fine too.
Note: this error was also present in PHP 5.2.1. In PHP 5.1.6, I got a
"glibc double free detected"-error.
Reproduce code:
---------------
<?php
echo "Opening connection...\n";
$connection = odbc_connect($dsn,"",""); //connect to dsn
echo "Executing SQL...\n";
$result = odbc_do($connection,$sqlstring);
//optional code to do something with resultset here
/*the following line crashes PHP with zend_mm_heap corrupted
commenting out this line doesn't help (since the result will be freed
automatically anyway*/
echo "Freeing...\n";
odbc_free_result($result);
echo "Closing...\n";
odbc_close($connection);
echo "Done.\n";
?>
Expected result:
----------------
Opening connection...
Executing SQL...
Freeing...
Closing...
Done.
Actual result:
--------------
Opening connection...
Executing SQL...
Freeing...
zend_mm_heap corrupted
--
Edit bug report at http://bugs.php.net/?id=42068&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=42068&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=42068&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=42068&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42068&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=42068&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42068&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42068&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42068&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42068&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42068&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=42068&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=42068&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42068&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42068&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42068&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42068&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42068&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42068&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42068&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42068&r=mysqlcfg