Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55782 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4227 invoked from network); 11 Oct 2011 21:12:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Oct 2011 21:12:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=tom@punkave.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=tom@punkave.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain punkave.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: tom@punkave.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:60897] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 94/72-26502-641B49E4 for ; Tue, 11 Oct 2011 17:12:38 -0400 Received: by vcbfk1 with SMTP id fk1so14356vcb.29 for ; Tue, 11 Oct 2011 14:12:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.31.41 with SMTP id x9mr20370267vdh.42.1318367555345; Tue, 11 Oct 2011 14:12:35 -0700 (PDT) Received: by 10.52.169.73 with HTTP; Tue, 11 Oct 2011 14:12:35 -0700 (PDT) In-Reply-To: References: Date: Tue, 11 Oct 2011 17:12:35 -0400 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: Re: PHP crashes with multiple autoloaders if autoloader after the first does not return a value From: tom@punkave.com (Tom Boutell) Update: actually, this was not my crashing bug, although it does still look suspicious - I don't see how retval gets cleaned up between invocations. My crashing bug appears to be triggered when an autoloader decides to unregister and re-register itself from inside the autoload() function. Specifically, Symfony's sfAutoloadAgain class does this, in an attempt to save us all from having to clear the autoloader cache when we add a class by doing it automatically and then giving autoloading one more try. My suspicion is that the PHP core's iteration over the list of autoloaders is not safe against this possibility and it winds up off the end of a list or referencing something previously removed. Any thoughts? On Tue, Oct 11, 2011 at 1:08 PM, Tom Boutell wrote: > Just opened a bug report: > > https://bugs.php.net/bug.php?id=60042 > > The documentation does not indicate that autoloader functions > registered with spl_autoload_register have to return anything, but if > an autoloader other than the first one returns no value, PHP crashes. > > This is because of a dangling pointer condition. 'retval' is > initialized at the top of spl_autoload_call but never re-initialized > to NULL after the return value of each autoloader is destroyed. If the > next autoloader has a return value, no harm is done, but if it does > not the dangling pointer is destroyed again. > > Many authors of autoloaders have resorted to returning true or false > in an educated guess at what they are supposed to do to avoid this > problem, but in fact it's just a core PHP bug - when the code is > working properly it doesn't actually care what the return value is. > > The patch is one line (: > > Wanted to bring this to folks' attention since it causes a lot of > frustration for those using multiple frameworks, libraries, etc. all > of which come with autoloaders. > > -- > Tom Boutell > P'unk Avenue > 215 755 1330 > punkave.com > window.punkave.com > -- Tom Boutell P'unk Avenue 215 755 1330 punkave.com window.punkave.com