php.net |  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
Votes:1
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
 [2012-05-06 14:40 UTC] giovanni dot g at gmail dot com
Description:
------------
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:
---------------
<?php

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;
  $c->m();
  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");
session_start();

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 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-07-17 09:56 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2012-07-17 09:56 UTC] ab@php.net
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] ab@php.net
-Status: Feedback +Status: Verified
 [2012-07-19 15:19 UTC] ab@php.net
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] rasmus@php.net
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] rasmus@php.net
-Status: Verified +Status: Duplicate
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 15 11:01:30 2024 UTC