php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25782 require( 'require.php' ) crashing Apache 1.3.28
Submitted: 2003-10-07 20:30 UTC Modified: 2003-10-12 22:34 UTC
From: akinder at technology-x dot com Assigned:
Status: Not a bug Package: Apache related
PHP Version: 5.0.0b1 (beta1) OS: Linux RedHat 9
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: akinder at technology-x dot com
New email:
PHP Version: OS:

 

 [2003-10-07 20:30 UTC] akinder at technology-x dot com
Description:
------------
When developing, I normally require or include all necessary files in one file top level, so that each script can require just one single file.
Normally this works fine, but starting last night, I found that if I store all these includes/requires in my typical "require.php" file and require it from my index.php, it crashes Apache.  If I delete the require.php from the directory, it works fine.  Also, if I rename the file to something like "global_includes.php" it works fine.  It only crashes if I put "require( 'require.php' );"

My other projects that use require.php still work fine, its just this one (under directory /whi7/).

Also of note, regardless to what file I require within my index.php, as long as require.php exists in the directory, it crashes Apache.  httpd -l  shows mod_php5

Reproduce code:
---------------
require.php:
<?php
require( 'openwhi/smaAPI.php' );

$api = new smaAPI();

?>

index.php:

<?php
require( 'require.php' );
//rest of page
?>

Expected result:
----------------
It should just require the require.php file and work like normal, just like the other projects.

Actual result:
--------------
The browser hangs, then stops loading the requested document and just sits on the one already open.  Apache's error_log shows:

[Tue Oct  7 20:38:29 2003] [notice] child pid 2858 exit signal Segmentation fault (11)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-10-07 20:53 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip

And if this happens with latest CVS snapshot, please provide
GDB backtrace of the crash.

 [2003-10-08 16:58 UTC] akinder at technology-x dot com
I'm using the php5 build 200310081730.
The crash still occurs, but when I run httpd -X through gdb, it just says "Program exited with code 01" and there isn't any stack.

I've also found some other things I need to add.
The directory struct that is crashing is as so:

/ (toplevel htdocs)
/whi7/ (working directory)
/whi7/require.php (if file is present, it crashes)
/whi7/index.php
/whi7/_inc/functions.php ( function file for whi7 )
/whi7/openwhi/smaAPI.php (filed required in require.php above)
/whi7/openwhi/require.php (OpenWHI's require.php file)
/whi7/openwhi/_inc/functions.php (OpenWHI's function file)

What I've found is that, if require.php is present, it won't crash.  BUT if require.php is present, AND it is requiring /openwhi/smaAPI.php, it will crash.
If /whi7/_inc/functions.php is required along with /openwhi/smaAPI.php, it won't crash, but says that "sma_data()" function didn't exist (which is a function in /openwhi/_inc/functions.php ).

The smaAPI.php file requires "require.php" in the /whi7/openwhi/ directory, which in turn requires the functions.php file from /whi7/openwhi/_inc/.

I'm beginning to think that PHP is entering some sort of infinite loop, if the /whi7/ require.php is named require.php and requires smaAPI, which requires require.php (under the /openwhi/ subdirectory)

Damn I've confused myself.. I'm not for sure if this is still a bug or just bad coding practice on my part.
 [2003-10-12 22:34 UTC] sniper@php.net
It's not PHP bug, you end up in a recursive infinite loop.
What you're doing is bad pracise, use require_once() and preferrably absolute paths when possible.

(Free hint: Try to minimize the use of require/include always, they're very expensive, rather have big files with everything than all that split to several small files)

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 12 05:01:33 2025 UTC