Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37364 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87166 invoked from network); 30 Apr 2008 16:52:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Apr 2008 16:52:17 -0000 X-Host-Fingerprint: 98.210.212.242 c-98-210-212-242.hsd1.ca.comcast.net Received: from [98.210.212.242] ([98.210.212.242:26789] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 30/D5-55591-0C3A8184 for ; Wed, 30 Apr 2008 12:52:16 -0400 Message-ID: <30.D5.55591.0C3A8184@pb1.pair.com> To: internals@lists.php.net Date: Wed, 30 Apr 2008 09:52:13 -0700 User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 98.210.212.242 Subject: Help: call_user_function() core dumps From: dhiru.pandey@sun.com (Dhiru Pandey) 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; ZVAL_STRINGL(args[0], "DHIRU ", 6, 0); ZVAL_LONG(args[1], 5L); call_user_function(EG(function_table), NULL, &funcname, &retval, 2, args TSRMLS_CC); ans = Z_STRVAL(retval); printf("%s\n", ans); PHP_EMBED_END_BLOCK(); return 0; } ======================================================================== When I run this program it core dumps with the following message: /export/home/dhiru/work/php/php-5.2.5/Zend/zend_variables.h(35) : Block 0x08049188 status: /export/home/dhiru/work/php/php-5.2.5/Zend/zend_variables.c(36) : Actual location (location was relayed) Invalid pointer: ((thread_id=0x4C45535F) != (expected=0xB78D26B0)) Segmentation fault (core dumped) When I step thru the debugger it appears that the function str_repeat call is successful via zend_call_function(), but after the call to the str_repeat function it tries to execute zend_ptr_stack_clear_multiple(TSRMLS_C), which in turn calls zend_mm_check_ptr() and something seems to go wrong here : #ifdef ZTS if (ZEND_MM_BAD_THREAD_ID(p)) { if (!silent) { zend_debug_alloc_output("Invalid pointer: ((thread_id=0x%0.8X) != (expected=0x%0.8X))\n", (long)p->thread_id, (long)tsrm_thread_id()); had_problems = 1; } else { return zend_mm_check_ptr(heap, ptr, 0 ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC); } } #endif Any help will be greatly appreciated Thanks, -Dhiru P.S.: I am using Ubuntu and PHP 5.2.5