Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:15216 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 61036 invoked by uid 1010); 27 Feb 2005 16:03:09 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 61021 invoked from network); 27 Feb 2005 16:03:09 -0000 Received: from unknown (HELO totalise.co.uk) (127.0.0.1) by localhost with SMTP; 27 Feb 2005 16:03:09 -0000 X-Host-Fingerprint: 80.189.94.52 smtp2.global.net.uk FreeBSD 4.7-5.2 (or MacOS X 10.2-10.3) (2) Received: from ([80.189.94.52:61762] helo=smtp2.global.net.uk) by pb1.pair.com (ecelerity HEAD r(5124)) with SMTP id 8B/05-43672-C3FE1224 for ; Sun, 27 Feb 2005 11:03:08 -0500 Received: from ps.189.60.110.dial.global.net.uk ([80.189.60.110] helo=bagpuss) by smtp2.global.net.uk with esmtp (Exim 4.24; FreeBSD) id 1D5Qsr-000406-2j for internals@lists.php.net; Sun, 27 Feb 2005 16:03:05 +0000 Reply-To: To: "PHP Internals" Date: Sun, 27 Feb 2005 16:04:58 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: AcUc5f7I91yLcNp4Sb6DxwAp/kVm4g== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Message-ID: Authenticated-Sender: Subject: php_stream_opendir again! From: frak@totalise.co.uk ("Mikey") Hello again, Well, two books (Advanced PHP Programming [very good] & Building Custom PHP Extensions [not so good]) and a bit of experimentation later, I have narrowed my problem down to the following: If I call php_stream_opendir from within an exposed function it works fine but dies with the segfault as earlier described when I try to call it from a helper function. For example: PHP_FUNCTION(tmpl_reload) { if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } php_stream *base_dir = NULL; php_stream_context *context = NULL; if (TMPL_G(template_dir) != NULL) base_dir = php_stream_opendir (TMPL_G(template_dir), ENFORCE_SAFE_MODE|REPORT_ERRORS, context); if (base_dir) { RETURN_BOOL (1); } else { RETURN_BOOL (0); } } This function works fine and always returns true/1, however: int do_reload () { // My declares php_stream *base_dir = NULL; php_stream_context *context = NULL; int count = 0; // Zend declares TSRMLS_FETCH(); // Start from scratch TMPL_G(tmpl_loaded) = 0; if (TMPL_G(template_dir) != NULL) base_dir = php_stream_opendir (TMPL_G(template_dir), ENFORCE_SAFE_MODE|REPORT_ERRORS, context); TMPL_G(tmpl_dir_valid) = (base_dir) ? 1 : 0; return 1; } Causes a segfault. So, my question is as follows - is there a specific way to declare helper functions so that they have whatever is available to the module functions so that I can avoid this segfault? Regards, Mikey -- "What are you doing with that cat dear, it looks half dead!" - Mrs Schroedinger