php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62849 cache error while using static class callback as session handler
Submitted: 2012-08-18 03:17 UTC Modified: 2016-11-18 21:24 UTC
From: sskaje at gmail dot com Assigned:
Status: Wont fix Package: APC (PECL)
PHP Version: 5.4.6 OS: CentOS 6.3
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: sskaje at gmail dot com
New email:
PHP Version: OS:

 

 [2012-08-18 03:17 UTC] sskaje at gmail dot com
Description:
------------
I tried to create a minimum code to reproduce a crash caused on php 5.4.6 + apc 3.1.12, but only got a warning at last.

Code can be found here: http://pastebin.com/0m08CNBR

I start the built-in web server: php  -S 0.0.0.0:8080 -c /usr/local/etc/php.ini

APC config in PHP.ini:
[apc]
extension=apc.so
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64M
apc.optimization = 1
apc.num_files_hint = 0
apc.ttl = 0
apc.gc_ttl = 3600
apc.cache_by_default = on


then i tried to visit that test script via browser: http://172.16.9.217:8080/test/index.php

Warning given by the built-in web server:

[root@localhost main]# php  -S 0.0.0.0:8080 -c /usr/local/etc/php.ini
PHP 5.4.6 Development Server started at Sat Aug 18 11:06:12 2012
Listening on http://0.0.0.0:8080
Document root is /usr/local/nginx/html/lehecai/control/main
Press Ctrl-C to quit.
[Sat Aug 18 11:06:16 2012] 172.16.6.100:65228 [200]: /test/index.php
[Sat Aug 18 11:06:17 2012] 172.16.6.100:65229 [200]: /test/index.php
[Sat Aug 18 11:06:17 2012] PHP Warning:  Invalid callback mySessionHandlerS::write, class 'mySessionHandlerS' not found in Unknown on line 0
[Sat Aug 18 11:06:17 2012] PHP Warning:  Unknown: Failed to write session data (user). Please verify that the current setting of session.save_path is correct () in Unknown on line 0
[Sat Aug 18 11:06:17 2012] PHP Warning:  Invalid callback mySessionHandlerS::close, class 'mySessionHandlerS' not found in Unknown on line 0
[Sat Aug 18 11:06:23 2012] 172.16.6.100:65230 [200]: /test/index.php
[Sat Aug 18 11:06:23 2012] PHP Warning:  Invalid callback mySessionHandlerS::write, class 'mySessionHandlerS' not found in Unknown on line 0
[Sat Aug 18 11:06:23 2012] PHP Warning:  Unknown: Failed to write session data (user). Please verify that the current setting of session.save_path is correct () in Unknown on line 0
[Sat Aug 18 11:06:23 2012] PHP Warning:  Invalid callback mySessionHandlerS::close, class 'mySessionHandlerS' not found in Unknown on line 0


You can see it works at the first time, then failure unless terminate and start a new server.

====================================================

What's more, i tried to get some dump of the crash i said above both under php-fpm and the built-in server.

bt info here: http://pastebin.com/b4pbjKra

Code reproducing this crash can't be given at this time, i'll try to update this issue.

Test script:
---------------
http://pastebin.com/0m08CNBR


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-08-18 03:21 UTC] sskaje at gmail dot com
The code in http://pastebin.com/0m08CNBR offered two different call to session_set_save_handler.

The commented one works well.
 [2012-08-18 03:55 UTC] rasmus@php.net
You realize that there is a session handler interface you can implement in PHP 
5.4 now, right? 

See: http://php.net/manual/en/class.sessionhandlerinterface.php

Not that we shouldn't fix this case in APC, but you don't need to write code like 
that anymore unless you need to be backward compatible with older versions.
 [2012-08-18 07:11 UTC] sskaje at gmail dot com
@rasmus yes i notice that before i figured out what caused the warning/crash directly.
And the best solution might be 
            if (function_exists('session_register_shutdown')) {
                session_register_shutdown();
            } else {
                register_shutdown_function('session_write_close');
            }
coz i want my code runnable under both 5.3 and 5.4 without too much modification.


What's more, 5.4 accepts the old style parameters as it accepted, but it warns/crashes only if i have apc loaded, without any literal error. So in my opinion this case should be fixed, maybe not now.

Thanks for your reply.
 [2016-11-18 21:24 UTC] kalle@php.net
-Status: Open +Status: Wont fix
 [2016-11-18 21:24 UTC] kalle@php.net
APC is no longer supported in favor of opcache that comes bundled with PHP, if you wish to use the user cache, then look at PECL/APCu.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Thu Jan 02 22:01:28 2025 UTC