|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32092 Session does not close file in /tmp/
Submitted: 2005-02-24 15:58 UTC Modified: 2005-02-25 12:34 UTC
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: stanislav dot voroniy at portavita dot nl Assigned:
Status: Closed Package: Session related
PHP Version: 4.3.10 OS: Linux
Private report: No CVE-ID: None
 [2005-02-24 15:58 UTC] stanislav dot voroniy at portavita dot nl
In my application running Apache 2.0.46/php 4.3.10 in some scripts after complte execution file in /tmp/sess_xxxxx stays open. I've done tracing of apache processes with strace and found the following:

process A do open /tmp/sess_ file, flock it, execute script, close connection, but does not close /tmp/sess_ file. Any further request within this session is haging - further processes try to flock /tmp/sess_ file that stays open in process A and gets infinitive wait within the flock syscall.

Reproduce code:
I can't reproduce it in separate script. But the same application under Apache 1.3/PHP 4.3.4 works fine.

Expected result:
Sessions hangs.

Actual result:
Normal run of scripts:
14:40:58.514489 open("/tmp/sess_89b3f6140bce299259e0f810037c2d59", O_RDWR|O_CREAT, 0600) = 29
14:40:58.514559 flock(29, LOCK_EX)      = 0
14:40:58.514604 fcntl64(29, F_SETFD, FD_CLOEXEC) = 0
14:40:58.514646 fstat64(29, {st_mode=S_IFREG|0600, st_size=1976, ...}) = 0
14:40:58.514728 pread(29, "xxxxx"..., 1976, 0) = 1976
14:40:58.667724 ftruncate(29, 0)        = 0
14:40:58.667807 pwrite(29, "xxxx"..., 1371, 0) = 1371
14:40:58.667923 close(29)               = 0

Broken scripts:14:35:15.776816 open("/tmp/sess_89b3f6140bce299259e0f810037c2d59", O_RDWR|O_CREAT, 0600) = 29
14:35:15.776879 flock(29, LOCK_EX)      = 0
14:35:15.776925 fcntl64(29, F_SETFD, FD_CLOEXEC) = 0
14:35:15.776966 fstat64(29, {st_mode=S_IFREG|0600, st_size=1976, ...}) = 0
14:35:15.777041 pread(29, "xxxxx" 1976, 0) = 1976
and no operation any more on file 29...

Next request within the same session:14:35:16.187099 open("/tmp/sess_89b3f6140bce299259e0f810037c2d59", O_RDWR|O_CREAT, 0600) = 29
14:35:16.187167 flock(29, LOCK_EX <unfinished ...>

In /proc/<pid>/fd/ of idle apache process after execution of "broken scripts" I can see file 29 -> /tmp/sess_... still open.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-02-24 16:25 UTC] stanislav dot voroniy at portavita dot nl
Adding to the end of the scripts call to session_write_close() solves the problem. But as far as I can understand it should be done automatically always, but some times it does not happens.
 [2005-02-25 11:33 UTC] stanislav dot voroniy at portavita dot nl
First reaction about the snapshot is not related to this bug, bau in fact another bug. In procedure configure checking for Oracle Instance Client always overwrites variable ext_shared from previous Oracle Home installation checking. Very bad!
The following patch solves the problem:
--- ext/oci8/config.m4.orig     2005-02-25 11:05:41.000000000 +0100
+++ ext/oci8/config.m4  2005-02-25 11:07:27.000000000 +0100
@@ -64,13 +64,17 @@
 [  --with-oci8[=DIR]       Include Oracle (OCI8) support using an ORACLE_HOME
                           install. The default DIR is ORACLE_HOME])

-PHP_ARG_WITH(oci8-instant-client, for Oracle (OCI8) support using Oracle Instant Client,
-[  --with-oci8-instant-client[=DIR]
+if test "$PHP_OCI8" = "no"; then
+  PHP_ARG_WITH(oci8-instant-client, for Oracle (OCI8) support using Oracle Instant Client,
+  [  --with-oci8-instant-client[=DIR]
                           Include Oracle (OCI8) support using
                           Oracle Instant Client. DIR is the directory with the
                           Instant Client libraries. On Linux it will default to
                           Other platforms will need to have it explicitly specified.])

 if test "$PHP_OCI8" != "no"; then

Also in make test the following test has failed:
FAIL Bug #31213 (Sideeffects caused by bug #29493) [ext/standard/tests/array/bug31213.phpt]

If my major problem is solved I'll report later.
 [2005-02-25 11:39 UTC] stanislav dot voroniy at portavita dot nl
The main problem in snapshot is solved. So fix bag in ext/oci8/config.m4 and release 4.3.11 ASAP.
 [2005-02-25 11:52 UTC]
What's the problem with oci8/config.m4?
--with-oci8 & --with-oci8-instant-client are mutually exclusive and you should NOT be able to use both these options in the same time.
 [2005-02-25 11:59 UTC] stanislav dot voroniy at portavita dot nl
I do have Oracle installed, I don't have Instant Client.
I've specified only one option - --with-oci8=shared, but in the run of the script after oci8 option oci8-instant client is checked, and it does not matter what you put in that option the 'case' statement always is executed and since instant client in 'no' or '*' state in my case variable ext_shared is always set to "no". Look in my patch - I've completelly excluded checking for option --with-oci8-instance-client if previously option --with-oci8 was set.
 [2005-02-25 12:34 UTC]
Fixed, thanks.
Next time please don't mess two different issues in the same report, fill new report instead.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Tue Mar 21 04:03:39 2023 UTC