php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46344 Possible memory-leak. autoload not always called
Submitted: 2008-10-20 11:40 UTC Modified: 2008-10-21 09:23 UTC
From: troelskn at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.2.6 OS: FreeBSD 7.0-RELEASE-p5
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: troelskn at gmail dot com
New email:
PHP Version: OS:

 

 [2008-10-20 11:40 UTC] troelskn at gmail dot com
Description:
------------
After upgrading to a new server, we started seeing very inexplicable bugs in the system. I *think* I traced it down to the autoload functionality. In some situations, the autoloader doesn't seem to be triggered. Reproducing the bug is extremely hard; If I alter the code of the classloader, the error goes away. Also, I can't reproduce it on other systems.

I am not sure if this is a problem with SPL, with PHP or perhaps with PDO, but my guess is that spl_autoload_register somehow allocates memory for the callback wrongly, allowing other code to overwrite it.

Full system details follows:

$ php --version
PHP 5.2.6 with Suhosin-Patch 0.9.6.2 (cli) (built: Aug 29 2008 10:03:19) 
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
$ uname -a
FreeBSD xxx.xxx.dk 7.0-RELEASE-p5 FreeBSD 7.0-RELEASE-p5 #0: Wed Oct  1 07:51:58 UTC 2008     root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC  amd64

Reproduce code:
---------------
http://pastebin.com/f4625a564

In addition, you need a file datadictionary.php, containing:

    class DataDictionary {}

Expected result:
----------------
OK .. class has loaded

Actual result:
--------------
PHP Fatal error:  Class 'DataDictionary' not found in /usr/home/tkn/test.php on line 89

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-21 00:27 UTC] colder@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

Could you please reduce the reproduce script as short as possible ?
Also, try without suhosin and see if you can still reproduce it.
 [2008-10-21 07:57 UTC] troelskn at gmail dot com
I'm not able to reduce the script any further. The behaviour is affected by the code, even when it shouldn't. For example, if I comment out line 13, the behaviour changes, even though this particular line is never executed.

Currently, we're just using the latest ports version from bsd. I'll see if I can try without Suhosin, but this is our production server, so I'll have to barter with our Sysadm about recompiling PHP.

Since I submitted the bug, I removed the use of spl_autoload_register and replaced with __autoload. This made the bug disappear in this test-script, but I later discovered it elsewhere in the system. This suggests that it has nothing to do with SPL.

I'm sorry I can't be more specific -- this is a very evasive bug.
 [2008-10-21 09:23 UTC] jani@php.net
As long as you don't use the sources (without any 3rd party patches) we provide, there is no bug.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 26 23:00:02 2025 UTC