Segment fault
| From: | Doug Dalton | Date: | Fri, 19 Mar 2004 20:05:09 +0000 |
| Subject: | Segment fault | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-181000@lists.php.net to get a copy of this message | ||
I am writting a php script that will be used in production, it connects to a imap server gets all the headers and stores them in a db:
Here is where it is crashing
0x28258ede in mm_cache () from /usr/local/lib/libc-client4.so.8
(gdb) bt
#0 0x28258ede in mm_cache () from /usr/local/lib/libc-client4.so.8
#1 0x2825b9a2 in mail_elt () from /usr/local/lib/libc-client4.so.8
#2 0x0809af8e in zif_imap_headers (ht=1, return_value=0x113196a4,
this_ptr=0x0, return_value_used=1)
at /usr/home/ddalton/src/php-4.3.4/ext/imap/php_imap.c:1048
#3 0x081c2b06 in execute (op_array=0x82acb24)
at /usr/home/ddalton/src/php-4.3.4/Zend/zend_execute.c:1616
#4 0x081b13a9 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
at /usr/home/ddalton/src/php-4.3.4/Zend/zend.c:884
#5 0x08179f5b in php_execute_script (primary_file=0xbfbff6fc)
at /usr/home/ddalton/src/php-4.3.4/main/main.c:1729
#6 0x081c8fa9 in main (argc=2, argv=0xbfbff76c)
at /usr/home/ddalton/src/php-4.3.4/sapi/cli/php_cli.c:819
#7 0x0806af85 in _start ()
it appears to run out of memory in the c-client, increasing the memory limit does not resolve the issue here are the key elements of the code:
include '../config.php';
while($row = $results->fetchRow(DB_FETCHMODE_ASSOC))
{
$cnt=0;
$successful=false;
extract ($row);
$connectstr=connectstr($bmserver,$bmssl,$bmtype);
$mbox = imap_open("\{$connectstr}", "$bmusername", "$bmpassword", OP_READONLY );
$list = imap_list($mbox, "\{$server}", "*");
if (is_array($list)) {
reset($list);
while (list($key, $val) = each($list))
{
@imap_reopen($mbox, $val, OP_READONLY );
if ( $mbox === false )
{
$mbox = imap_open("\{$connectstr}$val", "$bmusername", "$bmpassword", OP_READONLY );
}
$headers = @imap_headers($mbox);
$numEmails = sizeof($headers);
if ($numEmails!=0 && is_array($headers))
{
for($i = 0; $i < $numEmails; $i++)
{
$mailHeader = @imap_headerinfo($mbox, $i);
$from = $mailHeader->fromaddress;
$fromar=split(",",$from);
$xfrom=sizeof($fromar);
for ($y=0; $y < $xfrom; $y++)
{
$emails=parseEmailString($fromar[$y]);
if (insertemail ($emails))
$successful=true;
}
}
}
}
}
}