Hi,

Monday, August 11, 2003, 7:42:40 AM, you wrote:

MP> Thanks for the reply.  Kind of good to know I am not the only one having
MP> difficulties.  I too have arrays of objects - although had the problem when
MP> I was dealing with arrays that were only 2 or 3 items long - and also am
MP> passing references quite a bit.

MP> After several hours of going backwards, I seem to be back on the straight
MP> and narrow by tweaking my code so i don't read non-existant array elements.
MP> Incase this helps anyone else down the road ever, I'll elaborate:

MP> I have several object classes which manage arrays of objects.  They have
MP> member functions which return references to these objects. i.e.

MP> function &findObj($id)
MP> {
MP>     return ($this->objarray[$id]);
MP> }

MP> I realised my problems started when I started passing $id=0 into these
MP> functions.  No such id exists.  I thought this would be fine, because I was
MP> expecting to just get NULL back, and I tested against the return value.
MP> This did infact work, but seems to have also resulted in all the erratic
MP> problems I described in my first post.  I have changed the functions to the
MP> following form:

MP> function &findObj($id)
MP> {
MP>     if ($id)
MP>         return ($this->objarray[$id]);
MP> }

MP> and everything seems to be nice and stable again.  Maybe somebody who knows
MP> the Zend code might be able to work out the cause of these problems?  Is
MP> this the sort of thing I should send to one of the developer lists?  It
MP> would be nice to have the time to have a look myself, but my deadline is
MP> looming ominously so I need to crack on for now ...

MP> thanks again for the response,
MP> regards,
MP> Martin

MP> ----- Original Message ----- 
MP> From: "Mike Migurski" <[EMAIL PROTECTED]>
MP> To: "Martin Peck" <[EMAIL PROTECTED]>
MP> Cc: <[EMAIL PROTECTED]>
MP> Sent: Sunday, August 10, 2003 8:57 PM
MP> Subject: Re: [PHP] segmentation faults


>> >I have a large project underway which is (hopefully!) nearing completion,
>> >running on the latest stable release, 4.3.2.  However, strange things
>> >have started happening...
>> >
>> >My main page sometimes causes Apache to seg fault at some point during
>> >the execution (e.g. [Sun Aug 10 18:05:55 2003] [notice] child pid 29674
>> >exit signal Segmentation fault (11)). I thought I'd track through it to
>> >find out where the problem might be, but having sprinkled a few echo
>> >statements around it now isn't crashing any more.
>>
>> I have also had this problem, and asking about it here provided no help.
>>
>> Mine seems to be related to abnormally high numbers of instantiated
>> objects and large amounts of reference-passing. Occasionally Apache
>> children will die (with the error you've described), or spin out of
>> control and hog the CPU for a while (Apache 1.3.27, Red Hat 9, PHP 4.3.2).
>> I have not been able to track down the problem, though I did attempt to
>> re-create it using the command-line PHP interpreter to write Apache out of
>> the picture, and was not able to reproduce the errors.
>>
>> I've tried to route around them somewhat, and have been moderately
>> successful, except when they bump my CPU load to 100%. :-P
>>
>> ---------------------------------------------------------------------
>> michal migurski- contact info and pgp key:
>> sf/ca            http://mike.teczno.com/contact.html
>>
>>
>> -- 
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>

Most programs will crash with null pointers so I operate with error
reporting set to E_ALL and it helps when these sort of things happen.
A function should never trust what it is being fed :) so your solution
is the right way, I don't think you will get much sympathy from the
developers but it would not hurt to tell them.

-- 
regards,
Tom


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to