Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:73486 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60088 invoked from network); 31 Mar 2014 10:39:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2014 10:39:00 -0000 Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.215.10 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.215.10 mail.experimentalworks.net Received: from [217.114.215.10] ([217.114.215.10:59192] helo=mail.experimentalworks.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E0/E1-44499-3C549335 for ; Mon, 31 Mar 2014 05:38:59 -0500 Received: from [192.168.2.31] (ppp-188-174-47-142.dynamic.mnet-online.de [188.174.47.142]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: johannes@schlueters.de) by mail.experimentalworks.net (Postfix) with ESMTPSA id 7731046529; Mon, 31 Mar 2014 12:39:43 +0200 (CEST) To: Kajetan Dolinar Cc: internals@lists.php.net In-Reply-To: <61554d9f645998b2d0498ccd7da6f9e8@jesej.si> References: <61554d9f645998b2d0498ccd7da6f9e8@jesej.si> Content-Type: text/plain; charset="UTF-8" Date: Mon, 31 Mar 2014 12:38:26 +0200 Message-ID: <1396262306.2982.73.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Fwd: zend_std_get_method : Address 0xffffffff is not stack'd, malloc'd or (recently) free'd From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Mon, 2014-03-31 at 00:39 +0200, Kajetan Dolinar wrote: > Hi there, > > I may have missed the right list but please consider my problem as it This is a good place, usually I suggest using pecl-dev as there are less mails, so less chance of being overseen. > needs Zend internals expert attention and may be a Zend bug. I am > developing a PHP extension and have stmbled over a fault. The excerpt > from the valgrind output on that fault says > > Invalid read of size 4 > at 0x44EAA4: zend_std_get_method (zend_object_handlers.c:847) > by 0x47A035: ZEND_INIT_METHOD_CALL_SPEC_VAR_CONST_HANDLER > (zend_vm_execute.h:10461) > by 0x452D1D: execute (zend_vm_execute.h:107) > by 0x42C398: zend_execute_scripts (zend.c:1236) > by 0x1: ??? > Address 0xffffffff is not stack'd, malloc'd or (recently) free'd This won't help much, without any further information like code or at least PHP version. Apparently 5.3 was the last version where zend_std_get_method is lose to line 847 in later versions it's starting somewhere in the thousands ... but that's too little to guess the fault. > 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 .. > However, there are leaks because I have turned off my own system for > memory control. I am using quite a complicated interplay of allocated > memory as well as references to static data. I use > > void * phxy_data_start() { return (void *) &etext; } > void * phxy_variable_start() { return (void *) &edata; } > void * phxy_heap_start() { return (void *) &end; } > void * phxy_stack_start() { return sbrk(0); } > unsigned char phxy_is_heap(void * data) { > return (phxy_heap_start() <= data && data < phxy_stack_start()); > } > unsigned char phxy_is_data(void * data) { > return (data >= phxy_data_start()); > } > > to find out which data need freeing and which not (i.e. before any > free() I check with phxy_is_heap()). But for my PHP extension I dear not > use this so that phxy_is_heap() always returns false for any data - > hence memory leaks. Please advise me of a safe PHP Zend analogue for > that approach. 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. johannes