|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
29 - 5 = ?
Subscribe to this entry?

 [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: Mon Jul 15 17:01:30 2024 UTC