You are here: efree cause errors during resource de-allocation « PHP Programming Language « IT news, forums, messages
efree cause errors during resource de-allocation

Posted by askel on 10/17/07 20:42

I'm developing small extension that deals with resources. If I use
emalloc/efree for allocating freeing resource data I get random memory
corruption errors. If I replace emalloc/efree with malloc/free,
everything works fine. At least there are no errors produced. I'm
using PHP 4.4.8/Zend Engine 1.3.0/no any optimiser.

-------- myext.c ------
static int le_connections;

struct myconn {
...
}

static void _close_connection(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
struct myconn *conn = (struct myconn *) rsrc->ptr;
/*
Memory corruption happens during or after efree call
*** glibc detected *** php: malloc(): memory corruption: 0x082a5940
***
OR
*** glibc detected *** php: free(): invalid next size (fast):
0x082a58e8 ***
*/
efree(conn);
}

PHP_MINIT_FUNCTION(myext)
{
le_connections =
zend_register_list_destructors_ex(_close_connection, NULL, "my
connection", module_number);
}

PHP_FUNCTION(my_connect)
{
struct myconn *conn;
...
conn = emalloc(sizeof(struct myconn));
...
ZEND_REGISTER_RESOURCE(return_value, conn, le_connections);
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация