Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21454 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 40990 invoked by uid 1010); 9 Jan 2006 18:57:44 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 40975 invoked from network); 9 Jan 2006 18:57:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Jan 2006 18:57:44 -0000 X-Host-Fingerprint: 17.250.248.89 smtpout.mac.com FreeBSD 4.8-5.1 (or MacOS X 10.2-10.3) Received: from ([17.250.248.89:57714] helo=smtpout.mac.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id C8/28-23589-622B2C34 for ; Mon, 09 Jan 2006 13:57:44 -0500 Received: from mac.com (smtpin08-en2 [10.13.10.153]) by smtpout.mac.com (Xserve/8.12.11/smtpout02/MantshX 4.0) with ESMTP id k09IvcCG028971; Mon, 9 Jan 2006 10:57:39 -0800 (PST) Received: from [10.0.1.104] (c-24-98-128-251.hsd1.ga.comcast.net [24.98.128.251]) (authenticated bits=0) by mac.com (Xserve/smtpin08/MantshX 4.0) with ESMTP id k09IvaBV002468; Mon, 9 Jan 2006 10:57:37 -0800 (PST) In-Reply-To: References: <31.AA.06465.0C74FB34@pb1.pair.com> <7.0.1.0.2.20060108171105.063406b0@zend.com> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-ID: Cc: internals@lists.php.net Content-Transfer-Encoding: 7bit Date: Mon, 9 Jan 2006 13:57:32 -0500 To: Tim Starling X-Mailer: Apple Mail (2.746.2) Subject: Re: [PHP-DEV] 16-bit reference count in PHP 4's zval From: apinstein@mac.com (Alan Pinstein) It seems that the problem you're encountering could be fixed trivially by moving the initialization of $stuff into the constructor. However, it's difficult to tell from the provided code whether $stuff is intended as a static member... but if it's not, seems like a very simple fix... I don't personally know about PHP4 internals, but it would seem that the reason it breaks as-is is that ALL CacheEntry objects initially report to the same (statically created) empty array. So, moving it into the constructor would at least create n empty arrays rather than segfaulting. Right? Then you wouldn't even need to change your runtime environment (ie PHP version) to solve the problem. Alan On Jan 8, 2006, at 5:00 PM, Tim Starling wrote: > Zeev Suraski wrote: >> Tim, >> >> Your analysis was correct until the last sentence - PHP surely does >> support arrays with more than 64K entries. It just doesn't >> support the >> same entry being linked from more than 64K locations (which is much, >> much more rare occurrence). > > Well yes, I was just stirring. It's more common than you might > think though. > My own case was somewhat similar to this: > > class CacheEntry { > var $name; > var $stuff = array(); > > function CacheEntry( $name ) { > $this->name = $name; > } > } > > $cache = array(); > for ( $i=0; $i<100000; $i++) { > $cache[] = new CacheEntry( "Cache entry $i" ); > } > ?> > > ...which will segfault on exit due to the excess references to the > empty > array object created for the initialisation of the unused member > variable > $stuff. Generally speaking, arrays of objects with initialised but > unused > member variables will cause problems. Our code (MediaWiki) has > plenty of > such arrays, the reason we don't see this more often is because the > arrays > usually contain less than 64K entries. The size of the arrays > depend on user > input. > > -- Tim Starling > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >