Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73490 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69449 invoked from network); 31 Mar 2014 12:10:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2014 12:10:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=kajetan@jesej.si; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=kajetan@jesej.si; sender-id=pass Received-SPF: pass (pb1.pair.com: domain jesej.si designates 84.255.236.41 as permitted sender) X-PHP-List-Original-Sender: kajetan@jesej.si X-Host-Fingerprint: 84.255.236.41 mail.jesej.si Received: from [84.255.236.41] ([84.255.236.41:56134] helo=mail.jesej.si) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F1/63-44499-15B59335 for ; Mon, 31 Mar 2014 07:10:58 -0500 Received: from mail.jesej.si (localhost [127.0.0.1]) by mail.jesej.si (Postfix) with ESMTPA id 705F076133C for ; Mon, 31 Mar 2014 14:09:51 +0200 (CEST) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 31 Mar 2014 14:09:51 +0200 To: internals@lists.php.net In-Reply-To: <1396262306.2982.73.camel@guybrush> References: <61554d9f645998b2d0498ccd7da6f9e8@jesej.si> <1396262306.2982.73.camel@guybrush> Message-ID: <7a275f0b0f3d960c343fa59524129e0b@jesej.si> X-Sender: kajetan@jesej.si User-Agent: Roundcube Webmail/RCMAIL_VERSION Subject: Re: [PHP-DEV] Fwd: =?UTF-8?Q?zend=5Fstd=5Fget=5Fmethod=20=3A=20Ad?= =?UTF-8?Q?dress=20=30xffffffff=20is=20not=20stack=27d=2C=20malloc=27d=20o?= =?UTF-8?Q?r=20=28recently=29=20free=27d?= From: kajetan@jesej.si (Kajetan Dolinar) Johaness, thank you for your attention ... >> The reason most probably lies within my code, but I don't have enough >> PHP Zend engine >> hacking experience to get to it by myself - it's my first PHP >> extension. Much obliged >> for intuitions from experienced for what could bring about such kind >> of fault. > > Reduce you ode till it works or share more details .. Yes, that may now be the only possible way to procede. > Depends on what you want to use that memory for and what you optimize > for. i.e. if you want to stick data in PHP data structures it should be > emalloc'd with one block per item so PHP an free it. I would like to see from the address value itself whether that address was produced by e{m|re}alloc() so that I have to efree() it, or by pe{m|re}alloc() that I have to pefree(), or whether it falls within some other data segment such as static data which I should not free() in any way. For example: struct record { int id; char * name; . . . }; . . . struct record * a = emalloc(sizeof(struct record)); a->id = 1; a->name = estrdup("name1"); struct record * b = emalloc(sizeof(struct record)); b->id = 2; b->name = "name2"; Clearly, there should be efree(a->name) as well as efree(a). However, in case of b, only efree(b) is appropriate whereas efree(b->name) would produce an error. How can I find out whether an address belongs to efree() or to pefree() or to none of that? Kajetan