#42068 [Opn->Fbk]: zend_mm_heap corrupted error when freeing resultset with Intersystems' Cache

From: Date: Tue, 24 Jul 2007 12:01:44 +0000
Subject: #42068 [Opn->Fbk]: zend_mm_heap corrupted error when freeing resultset with Intersystems' Cache
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-115375@lists.php.net to get a copy of this message
ID: 42068 Updated by: jani@php.net Reported By: macuyiko at gmail dot com -Status: Open +Status: Feedback Bug Type: ODBC related Operating System: Linux (64bit) PHP Version: 5.2.3 New Comment: Try using the PDO ODBC instead. It is known to work better in most cases. Previous Comments: ------------------------------------------------------------------------ [2007-07-22 14:17:45] macuyiko at gmail dot com 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 this bug report at http://bugs.php.net/?id=42068&edit=1

« previous php.bugs (#115375) next »