|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61965 post-shutdown actions in session_set_save_handler cause problems
Submitted: 2012-05-06 14:40 UTC Modified: 2012-07-19 17:41 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: giovanni dot g at gmail dot com Assigned:
Status: Duplicate Package: APC (PECL)
PHP Version: 5.3.12 OS: Linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: giovanni dot g at gmail dot com
New email:
PHP Version: OS:


 [2012-05-06 14:40 UTC] giovanni dot g at gmail dot com
With APC, after the script has been cached i.e. after 1 second from the first hit without modifying or restarting apache, the script causes an error on the $c = new C;" line
it seems that APC loses all the names data because i originally ran into this bug for trying to access self::CONST_NAME in an previously existing instance, then i found out that not only it loses the class constants, but the class names as well.

Test script:

function sess_open($savePath, $sessionName) {
  return true;
function sess_close() {
  return true;
function sess_read($sessionId) {
  return "";
function sess_write($sessionId, $data) {
  $c = new C;
  return true;
function sess_destroy($sessionId) {
  return true;
function sess_gc($lifetime) {
  return true;

session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc");

class C {
  public function m() {
    print "ok\n";

print "finish\n";

Expected result:
finish ok

Actual result:
finish Fatal error: Class 'C' not found in (omitted) on line 13 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-17 09:56 UTC]
-Status: Open +Status: Feedback
 [2012-07-17 09:56 UTC]
Can you still reproduce this with the current APC trunk? I can not using 5.3 
branch and APC trunk.
 [2012-07-19 15:19 UTC]
-Status: Feedback +Status: Verified
 [2012-07-19 15:19 UTC]
Now I can reproduce it too. The issue is, that the session write handler happens 
to be called on request shutdown. However APCs request shutdown handler removes 
all the classes from EG (previously inserted there on request start) and is 
called before session. For the very first time APC has nothing to insert as the 
classes are read by ZE. All the subsequent calls a class is inserted and removed 
into EG by APC.

So two things from me as the conclusion :)
- why the classes are deleted there, but not the functions?
- it would be nice to have runtime module deps
 [2012-07-19 17:41 UTC]
This is a duplicate of bug 59386 and it isn't really a PHP bug. The easy 
workaround is to call session_write_close() when you don't need anything from 
your session anymore.
 [2012-07-19 17:41 UTC]
-Status: Verified +Status: Duplicate
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 16:01:28 2024 UTC