#20658 [Com]: segfault after calling array_walk

2002-11-28 Thread chris-php
 ID:   20658
 Comment by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Feedback
 Bug Type: Reproducible crash
 Operating System: Linux 2.4.19-pre4
 PHP Version:  4CVS-2002-11-26 (stable)
 New Comment:

Seems to be fixed now, thanks for the help.


Previous Comments:


[2002-11-26 17:02:17] [EMAIL PROTECTED]

Yep. I found a bug in error reporting code while investigating
array_walk() and fixed it. Now please try the latest one and it will
give you a bit more useful information, I suppose.



[2002-11-26 16:48:36] [EMAIL PROTECTED]

The one I tried and quoted in the bug report was less than 2 hours old
at the time of the reporting.

Has anything changed between then and now?



[2002-11-26 15:38:46] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip



[2002-11-26 13:41:48] [EMAIL PROTECTED]

I get a segfault after calling array_walk, in this portion of a
script:

function get_flat($packageid = 0) {
if ($packageid == $this->lastflatid)
return $this->flat;
$this->lastflatid = $packageid;
$this->flat = array();
array_walk(&$this->tree[$packageid], array(&$this,
"get_flat_callback"));
return $this->flat;
}

function get_flat_callback($val, $key) {
if (is_array($val)) {
if (is_int($key))
$this->flat[$key] =& $val;
array_walk(&$val, array(&$this, "get_flat_callback"));
}
}

The entire script can be viewed here:

http://dali.deviantart.com/~chris/themetree.phps

For some odd reason, this code is called twice in the page, however the
bug only manifests itself the second time the function is called (which
was why I added the first three lines of get_flat() as a temporary
workaround) however it is completely reproducible. I could also
reproduce it in 4.2.2, and it printed an error message to the php
error_log:

[26-Nov-2002 10:16:31] PHP Warning:  Unable to call (null)() - function
does not exist in /www/shared/themetree.php on line 67

A backtrace from a snapshot from an hour or two ago is below:

Program received signal SIGSEGV, Segmentation fault.
0x4038fd10 in xbuf_format_converter (xbuf=0xbfff9a78,
fmt=0x403ddd60 "Unable to call %s() - function does not exist",
ap=0xbfff9b30) at
/home/chris/php4-STABLE-200211261830/main/spprintf.c:438
438 s_len =
strlen(s);
(gdb) bt
#0  0x4038fd10 in xbuf_format_converter (xbuf=0xbfff9a78,
fmt=0x403ddd60 "Unable to call %s() - function does not exist",
ap=0xbfff9b30) at
/home/chris/php4-STABLE-200211261830/main/spprintf.c:438
#1  0x403902e1 in vspprintf (pbuf=0xbfff9ad8, max_len=0,
format=0x403ddd60 "Unable to call %s() - function does not exist",
ap=0xbfff9b30) at
/home/chris/php4-STABLE-200211261830/main/spprintf.c:622
#2  0x4038c3cc in php_verror (docref=0x0, params=0x403e9f93 "",
type=2,
format=0x403ddd60 "Unable to call %s() - function does not exist",
args=0xbfff9b30) at
/home/chris/php4-STABLE-200211261830/main/main.c:399
#3  0x4038c723 in php_error_docref0 (docref=0x0, type=2,
format=0x403ddd60 "Unable to call %s() - function does not exist")
at /home/chris/php4-STABLE-200211261830/main/main.c:484
#4  0x403178bb in php_array_walk (target_hash=0x81ca984, userdata=0x0)
at /home/chris/php4-STABLE-200211261830/ext/standard/array.c:983
#5  0x403179fd in zif_array_walk (ht=2, return_value=0x8254c8c,
this_ptr=0x0,
return_value_used=0)
at /home/chris/php4-STABLE-200211261830/ext/standard/array.c:1023
#6  0x403cb211 in execute (op_array=0x8254b7c)
at /home/chris/php4-STABLE-200211261830/Zend/zend_execute.c:1598
#7  0x403aff76 in call_user_function_ex (function_table=0x8253a00,
object_pp=0x8209a68, function_name=0x8253644,
retval_ptr_ptr=0xbfffa1a8,
param_count=2, params=0xbfffa1c0, no_separation=0,
symbol_table=0x0)
at
/home/chris/php4-STABLE-200211261830/Zend/zend_execute_API.c:557
#8  0x40317889 in php_array_walk (target_hash=0x824e4c4, userdata=0x0)
at /home/chris/php4-STABLE-200211261830/ext/standard/array.c:978
#9  0x403179fd in zif_array_walk (ht=2, return_value=0x825547c,
this_ptr=0x0,
return_value_used=0)
at /home/chris/php4-STABLE-200211261830/ext/standard/array.c:1023
#10 0x403cb211 in execute (op_array=0x8254b7c)
at /home/chris/php4-STABLE-200211261830/Zend/zend_execute.c:1598
#11 0x403aff76 in call_user_function_ex (function_table=0x8253a00,
object_pp=0x820aab0, function_name=0x825646c

#20658 [Com]: segfault after calling array_walk

2002-11-26 Thread chris-php
 ID:   20658
 Comment by:   [EMAIL PROTECTED]
 Reported By:  [EMAIL PROTECTED]
 Status:   Feedback
 Bug Type: Reproducible crash
 Operating System: Linux 2.4.19-pre4
 PHP Version:  4CVS-2002-11-26 (stable)
 New Comment:

The one I tried and quoted in the bug report was less than 2 hours old
at the time of the reporting.

Has anything changed between then and now?


Previous Comments:


[2002-11-26 15:38:46] [EMAIL PROTECTED]

Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip



[2002-11-26 13:41:48] [EMAIL PROTECTED]

I get a segfault after calling array_walk, in this portion of a
script:

function get_flat($packageid = 0) {
if ($packageid == $this->lastflatid)
return $this->flat;
$this->lastflatid = $packageid;
$this->flat = array();
array_walk(&$this->tree[$packageid], array(&$this,
"get_flat_callback"));
return $this->flat;
}

function get_flat_callback($val, $key) {
if (is_array($val)) {
if (is_int($key))
$this->flat[$key] =& $val;
array_walk(&$val, array(&$this, "get_flat_callback"));
}
}

The entire script can be viewed here:

http://dali.deviantart.com/~chris/themetree.phps

For some odd reason, this code is called twice in the page, however the
bug only manifests itself the second time the function is called (which
was why I added the first three lines of get_flat() as a temporary
workaround) however it is completely reproducible. I could also
reproduce it in 4.2.2, and it printed an error message to the php
error_log:

[26-Nov-2002 10:16:31] PHP Warning:  Unable to call (null)() - function
does not exist in /www/shared/themetree.php on line 67

A backtrace from a snapshot from an hour or two ago is below:

Program received signal SIGSEGV, Segmentation fault.
0x4038fd10 in xbuf_format_converter (xbuf=0xbfff9a78,
fmt=0x403ddd60 "Unable to call %s() - function does not exist",
ap=0xbfff9b30) at
/home/chris/php4-STABLE-200211261830/main/spprintf.c:438
438 s_len =
strlen(s);
(gdb) bt
#0  0x4038fd10 in xbuf_format_converter (xbuf=0xbfff9a78,
fmt=0x403ddd60 "Unable to call %s() - function does not exist",
ap=0xbfff9b30) at
/home/chris/php4-STABLE-200211261830/main/spprintf.c:438
#1  0x403902e1 in vspprintf (pbuf=0xbfff9ad8, max_len=0,
format=0x403ddd60 "Unable to call %s() - function does not exist",
ap=0xbfff9b30) at
/home/chris/php4-STABLE-200211261830/main/spprintf.c:622
#2  0x4038c3cc in php_verror (docref=0x0, params=0x403e9f93 "",
type=2,
format=0x403ddd60 "Unable to call %s() - function does not exist",
args=0xbfff9b30) at
/home/chris/php4-STABLE-200211261830/main/main.c:399
#3  0x4038c723 in php_error_docref0 (docref=0x0, type=2,
format=0x403ddd60 "Unable to call %s() - function does not exist")
at /home/chris/php4-STABLE-200211261830/main/main.c:484
#4  0x403178bb in php_array_walk (target_hash=0x81ca984, userdata=0x0)
at /home/chris/php4-STABLE-200211261830/ext/standard/array.c:983
#5  0x403179fd in zif_array_walk (ht=2, return_value=0x8254c8c,
this_ptr=0x0,
return_value_used=0)
at /home/chris/php4-STABLE-200211261830/ext/standard/array.c:1023
#6  0x403cb211 in execute (op_array=0x8254b7c)
at /home/chris/php4-STABLE-200211261830/Zend/zend_execute.c:1598
#7  0x403aff76 in call_user_function_ex (function_table=0x8253a00,
object_pp=0x8209a68, function_name=0x8253644,
retval_ptr_ptr=0xbfffa1a8,
param_count=2, params=0xbfffa1c0, no_separation=0,
symbol_table=0x0)
at
/home/chris/php4-STABLE-200211261830/Zend/zend_execute_API.c:557
#8  0x40317889 in php_array_walk (target_hash=0x824e4c4, userdata=0x0)
at /home/chris/php4-STABLE-200211261830/ext/standard/array.c:978
#9  0x403179fd in zif_array_walk (ht=2, return_value=0x825547c,
this_ptr=0x0,
return_value_used=0)
at /home/chris/php4-STABLE-200211261830/ext/standard/array.c:1023
#10 0x403cb211 in execute (op_array=0x8254b7c)
at /home/chris/php4-STABLE-200211261830/Zend/zend_execute.c:1598
#11 0x403aff76 in call_user_function_ex (function_table=0x8253a00,
object_pp=0x820aab0, function_name=0x825646c,
retval_ptr_ptr=0xbfffa7f8,
param_count=2, params=0xbfffa810, no_separation=0,
symbol_table=0x0)
at
/home/chris/php4-STABLE-200211261830/Zend/zend_execute_API.c:557
#12 0x40317889 in php_array_walk (target_hash=0x8209914, userdata=0x0)
at /home/chris/php4-STABLE-200211261830/ext/standard/array.c:978
#13 0x403179fd in zif_array_walk (ht=2, return_value=0x820cc94,
this_ptr=0x0,
return_value_used=0)
at /home/chris/php4-STABLE-2002