php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39519 Calling an script in a current session via fopen wrappers freezes Apache
Submitted: 2006-11-15 01:48 UTC Modified: 2006-11-15 09:40 UTC
From: sw4u at gmx dot net Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.4.4 OS: Debian GNU/Linux
Private report: No CVE-ID: None
 [2006-11-15 01:48 UTC] sw4u at gmx dot net
Description:
------------
If you have two seperate scripts with session_start() and you read one via fopen wrappers Apache webserver freezes.

Tested on
Apache/2.0.54 (Debian GNU/Linux)
Server API Apache 2.0 Handler
--enable-trans-sid
session.auto_start Off
session.bug_compat_42 On
session.name PHPSESSID
session.use_cookies On
session.use_only_cookies Off
session.use_trans_sid Off


Reproduce code:
---------------
script a.php
---
<?php

session_start();
$_SESSION["foo"] = "bar";
echo session_name() ."<br />";
echo session_id() ."<br />";
echo $_SESSION["foo"] ."<br />";

echo implode("", file("http://" . $_SERVER["HTTP_HOST"] . "/b.php?" . session_name() . "=" . session_id()));

?>
---

script b.php
---
<?php

session_start();
echo session_name() ."<br />";
echo session_id() ."<br />";
echo $_SESSION["foo"] ."<br />";

?>
---


Expected result:
----------------
PHPSESSID
some_session_id_here
bar
PHPSESSID
same_session_id_here
bar


Actual result:
--------------
Apache freezes, no heavy load, no error message, no logfile entry.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-15 09:40 UTC] tony2001@php.net
This is called "deadlock" and you did it yourself.
Session file is locked, so every apache request will wait for the previous one to finish before using it.
You're sending a request using the same session ID, while the session file is locked, so we got the following situation:
- a.php has locked session and is still executing, waiting for file().
- but file() will never end, because b.php is waiting for session to be unlocked and that won't happen until a.php is finished executing.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 16:01:35 2024 UTC