|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26697 calling class_exists on a nonexistent class in __autoload results in segfault
Submitted: 2003-12-22 16:03 UTC Modified: 2003-12-23 05:41 UTC
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: arjen at glas dot its dot tudelft dot nl Assigned: helly (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.0b3 OS: *
Private report: No CVE-ID: None
 [2003-12-22 16:03 UTC] arjen at glas dot its dot tudelft dot nl
When calling class_exists on a nonexistent classname in __autoload, you'll get a segfault.

This is in beta1, beta2 and beta3 (and now I had the time to create a testcase and do a report). Which ran under apache2 (2.0.48) on gentoo linux.

And then I saw this report:
So I downloaded the php5-200312222030 snapshot and there it also segfaults...

Reproduce code:
function __autoload($classname)
        echo "This won't be reached due to a segfault";

$test = new test();



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-22 18:50 UTC] davidc at blesys dot com
What happens, I think, is that __autoload starts recursing endlessly. Do this:

  function __autoload ($n) {
global $autotracker; $n=strtolower($n);
 if ($autotracker==$n)die("Attempting to autoload $n again"); 
....//rest of function __autoload

}//end __autoload
Probably a bug, but rather easy to fix by the client programmer. I think the bug I found today w/ thrown exceptions is much more dangerous ( because you can't really fix it for all cases.
 [2003-12-23 05:41 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Jun 18 00:01:32 2024 UTC