Re: foreach segfaults on array built by extension
| From: | Wez Furlong | Date: | Wed, 13 Apr 2005 02:12:08 +0000 |
| Subject: | Re: foreach segfaults on array built by extension | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-2262@lists.php.net to get a copy of this message | ||
You code doesn't look wrong.
Knowing which php version you're running, and a backtrace would help
know for sure.
valgrind might also reveal something useful (although I don't think
that'll work on osx).
--Wez.
On 4/12/05, John LeSueur <john@supernerd.com> wrote:
> It appears that I'm building an array in such a way as to make foreach
> segfault. I can print_r() or var_dump, or anything else, but foreach
> segfaults. I figure
> I must be doing something wrong, but I can't tell what it is.
>
> As a simple example, in the extension I do:
>
> PHP_FUNCTION(zeroconf_test)
> {
> if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "") == FAILURE) {
> return;
> }
> array_init(return_value);
> add_next_index_stringl(return_value, "test", 4,1);
> add_next_index_stringl(return_value, "test", 4,1);
> add_next_index_stringl(return_value, "test", 4,1);
> }
>
> in a test script I do:
>
> <?
> $array = zeroconf_test();
> foreach($array1 as $service);
> {
> echo($service . "\n");
> }
> ?>
>
> After it prints the first test, it segfaults.
>
> Any ideas what I did wrong?
>
> John LeSueur
>
> --
> PECL development discussion Mailing List (http://pecl.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>