Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:38858 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82341 invoked from network); 8 Jul 2008 14:59:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jul 2008 14:59:49 -0000 Authentication-Results: pb1.pair.com header.from=derick@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=derick@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 82.94.239.7 as permitted sender) X-PHP-List-Original-Sender: derick@php.net X-Host-Fingerprint: 82.94.239.7 mail.jdi-ict.nl Linux 2.6 Received: from [82.94.239.7] ([82.94.239.7:38381] helo=mail.jdi-ict.nl) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F0/29-32540-2E083784 for ; Tue, 08 Jul 2008 10:59:47 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.jdi-ict.nl (8.13.7/8.12.11) with ESMTP id m68ExgNq010534; Tue, 8 Jul 2008 16:59:43 +0200 Date: Tue, 8 Jul 2008 16:59:43 +0200 (CEST) X-X-Sender: derick@kossu.ez.no To: Joe Orton cc: internals@lists.php.net In-Reply-To: <20080708144049.GA17307@redhat.com> Message-ID: References: <20080708144049.GA17307@redhat.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Subject: Re: [PHP-DEV] [PATCH] ext/date tzinfo structure references From: derick@php.net (Derick Rethans) On Tue, 8 Jul 2008, Joe Orton wrote: > The result of calling getTimezone() on a Date object results in a > DateTimeZone object with a reference to the dateobj->time->tz_info > object which may get later destroyed. > > This can cause unexpected script behaviour or interpreter crashes, test > case in attachment (1). > > When I fixed this the obvious way, per attachment 3, by adding a clone, > I wondered where the cloned tzinfo structures would get destroyed and I > can't see anywhere. > > After looking at this further - so far as I can tell, the duplication of > the tzinfo structures throughout this code is not actually necessary; > when the structures are created they are referenced from the global > tzcache and will hence last "forever" anyway. The structures are not > changed anywhere either, again AFAICT; though they aren't treated as > const so maybe I'm missing something there. > > So simply copying pointers around would simplify the code, fix leaks and > fix the bug as well. That's attachment (2). > > What do you think? Sounds sane... I was going to have a look at this tonight and do something similar - this saves some work. I'll see if it fixes all leaks, and commit it if it works fine. Thanks for the patch. regards, Derick -- Derick Rethans http://derickrethans.nl | http://ezcomponents.org | http://xdebug.org