Using `SessionHandler` doesn't always close session file
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?php
session_set_save_handler(new \SessionHandler, true);
session_start([
'save_path' => __DIR__,
]);
$_SESSION['test'] = function () {};
If you make a request to this you'll see a fatal error due to the serialization failing, if you try and make another request the file is still locked and the request hangs waiting for the lock to be released. Removing the session_set_save_handler() is sufficient to fix the problem. From what I can tell ps_close_user is called but it never appears to make the call to SessionHandler::close().
I've managed to replicate this behaviour on FPM (ZTS and NTS) and CLI server.
I've written a test: 88f32f48e2b6e7fd3554aef8d255f88d02a4e8db
PHP Version
8.3.11 and 8.3.13-dev
Operating System
Debian/Ubuntu
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction and test at commit 88f32f48e2b6e7fd3554aef8d255f88d02a4e8db, then trace ps_close_user and the SessionHandler::close() callback in the session implementation. Exercise the case under FPM or the CLI server. Done means the failing serialization request no longer leaves the session file locked and the regression test passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100