Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55780 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 80036 invoked from network); 11 Oct 2011 17:09:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 11 Oct 2011 17:09:02 -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:54848] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B1/4F-26502-C28749E4 for ; Tue, 11 Oct 2011 13:09:01 -0400 Received: by vcbfk1 with SMTP id fk1so6849307vcb.29 for ; Tue, 11 Oct 2011 10:08:58 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.36.106 with SMTP id p10mr19218415vdj.76.1318352938348; Tue, 11 Oct 2011 10:08:58 -0700 (PDT) Received: by 10.52.169.73 with HTTP; Tue, 11 Oct 2011 10:08:58 -0700 (PDT) Date: Tue, 11 Oct 2011 13:08:58 -0400 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Subject: PHP crashes with multiple autoloaders if autoloader after the first does not return a value From: tom@punkave.com (Tom Boutell) 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