efree cause errors during resource de-allocation
efree cause errors during resource de-allocation
am 17.10.2007 22:42:38 von askel
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);
}
Re: efree cause errors during resource de-allocation
am 18.10.2007 15:12:27 von Steve
"askel" wrote in message
news:1192637234.457240.125790@k35g2000prh.googlegroups.com.. .
> 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 ------
while this is a programming question and about php, it is not a php
programming question. try a c or c++ newsgroup.
Re: efree cause errors during resource de-allocation
am 26.10.2007 02:44:24 von askel
On Oct 18, 9:12 am, "Steve" wrote:
> "askel" wrote in message
>
> news:1192637234.457240.125790@k35g2000prh.googlegroups.com.. .
>
> > 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 withmalloc/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 ------
>
> while this is a programming question and about php, it is not a php
> programming question. try a c or c++ newsgroup.
This is Zend API question and has little to none relation to C/C++.
Re: efree cause errors during resource de-allocation
am 26.10.2007 05:54:23 von Jerry Stuckle
askel wrote:
> On Oct 18, 9:12 am, "Steve" wrote:
>> "askel" wrote in message
>>
>> news:1192637234.457240.125790@k35g2000prh.googlegroups.com.. .
>>
>>> 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 withmalloc/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 ------
>> while this is a programming question and about php, it is not a php
>> programming question. try a c or c++ newsgroup.
>
> This is Zend API question and has little to none relation to C/C++.
>
>
But it has nothing to do with programming in PHP. You're writing C
code, not PHP.
Try asking on the Zend site.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================