Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37380 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17039 invoked from network); 30 Apr 2008 18:16:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2008 18:16:35 -0000 Authentication-Results: pb1.pair.com header.from=johannes@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=johannes@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 83.243.58.163 as permitted sender) X-PHP-List-Original-Sender: johannes@php.net X-Host-Fingerprint: 83.243.58.163 mail4.netbeat.de Received: from [83.243.58.163] ([83.243.58.163:53765] helo=mail4.netbeat.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 77/90-13507-087B8184 for ; Wed, 30 Apr 2008 14:16:34 -0400 Received: (qmail 8021 invoked by uid 507); 30 Apr 2008 18:16:27 -0000 Received: from unknown (HELO ?192.168.1.102?) (postmaster%schlueters.de@88.217.24.239) by mail4.netbeat.de with ESMTPA; 30 Apr 2008 18:16:27 -0000 To: Dhiru Pandey Cc: internals@lists.php.net In-Reply-To: <30.D5.55591.0C3A8184@pb1.pair.com> References: <30.D5.55591.0C3A8184@pb1.pair.com> Content-Type: text/plain Date: Wed, 30 Apr 2008 20:16:25 +0200 Message-ID: <1209579385.6012.3.camel@goldfinger> Mime-Version: 1.0 X-Mailer: Evolution 2.12.3 (2.12.3-4.fc8) Content-Transfer-Encoding: 7bit Subject: Re: Help: call_user_function() core dumps From: johannes@php.net (Johannes =?ISO-8859-1?Q?Schl=FCter?=) Hi, On Wed, 2008-04-30 at 09:52 -0700, Dhiru Pandey wrote: > I am new to PHP extension writing and embedding. Following the book from > Sara Goleman - Extending and Embedding PHP (Developer's Library) > I wrote the following program based on her example in Chap. 20 > > =================================================================== > #include > #include > > #include > > int main(int argc, char** argv) { > PHP_EMBED_START_BLOCK(argc, argv); > > zval* args[2]; > zval funcname; > zval input_str; > zval count; > zval retval; > char* ans; > ZVAL_STRING(&funcname, "str_repeat", 0); > args[0] = &input_str; > args[1] = &count; You have to use emalloc'ed memory for (basically) everything you give to the engine and no pointers to local variables else the engine tries to free these local variables. johannes