#26005 [Com]: Random "cannot change the session's ini settings" errors

From: Date: Mon, 23 Feb 2004 12:11:45 +0000
Subject: #26005 [Com]: Random "cannot change the session's ini settings" errors
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-55366@lists.php.net to get a copy of this message
 ID:               26005
 Comment by:       jsnajdr at kerio dot com
 Reported By:      parsnip11 at hotmail dot com
 Status:           No Feedback
 Bug Type:         Session related
 Operating System: windows 2000 iis 5
 PHP Version:      4CVS-2003-10-31
 New Comment:

This is a patch that stopped crashing for me:

*** php-4.3.4/ext/session/session.c	Wed Oct  8 12:25:39 2003
--- php-4.3.4-n/ext/session/session.c	Tue Dec  9 11:36:24 2003
***************
*** 1543,1548 ****
--- 1543,1556 ----
  	}
  }
  
+ static void php_session_init_globals(php_ps_globals *ps_globals
TSRMLS_DC)
+ {
+ 	ps_globals->id = NULL;
+ 	ps_globals->session_status = php_session_none;
+ 	ps_globals->mod_data = NULL;
+ 	ps_globals->http_session_vars = NULL;
+ }
+ 
  static void php_rinit_session_globals(TSRMLS_D)
  {		
  	PS(id) = NULL;
***************
*** 1618,1624 ****
  #ifdef ZTS
  	php_ps_globals *ps_globals;
  
! 	ts_allocate_id(&ps_globals_id, sizeof(php_ps_globals), NULL, NULL);
  	ps_globals = ts_resource(ps_globals_id);
  #endif
  
--- 1626,1632 ----
  #ifdef ZTS
  	php_ps_globals *ps_globals;
  
! 	ts_allocate_id(&ps_globals_id, sizeof(php_ps_globals),
(ts_allocate_ctor) php_session_init_globals, NULL);
  	ps_globals = ts_resource(ps_globals_id);
  #endif


Previous Comments:
------------------------------------------------------------------------

[2004-02-09 18:44:35] admin at sistemasdinamicos dot com dot ar

I'm also having this issue.
Database error: 
MySQL Error: 1062 (Duplicate entry
'Sid-dec6275d91b72031c6db12dfd7f59e9e' for key 1)
Session halted.
Warning: Unknown(): A session is active. You cannot change the session
module's ini settings at this time. in Unknown on line 0

I'm using phplib 7.4 new session_custom. It uses
session_module_name('user') to use phplib's ct_sql container to store
session data in db.

The error occurs when I reload the page too fast. Another strange
thing, it happens in Opera 7, not in IE 6 (I think because IE can't
reload as fast as Opera).

When I use $sess->freeze() phplib's function at the end of the script
the error never happens, no matter how fast you reload the page. But I
don't want to use it, because I much prefer use directly
$_SESSION['var'] and if you do $sess->freeze() session variables got
screwed and if you don't the mentioned error appear.

Using php 4.3.4 and Apache 2.0.40 

Adio!

------------------------------------------------------------------------

[2004-01-02 07:32:15] mtimdog at comcast dot net

Let me rephrase that.  Oscommerce's session handling code is what
breaks php 4.3.x, I downgraded to 4.2.3 and no problem.  Note, was a
default install of oscommerce from oscommerce.com.  Try yourself, takes
roughly 15 minutes to install (most likely < 5).

------------------------------------------------------------------------

[2003-12-31 13:19:29] mtimdog at comcast dot net

I recently upgraded to 4.3.4 on my laptop (using apache) and am getting
this error as well.  to produce this code I have a simple redirect
statement
<meta http-equiv="refresh" content="1;index.php">

that redirects from index.html to index.php.

On the index.php page (oscommerce site), it makes/resets the session
variable or whatever oscommerce does.

------------------------------------------------------------------------

[2003-12-13 19:32:54] mrjack at online dot fr

I have a similar problem on a linux box running version 4.3.4 and
apache 2.0.48.
I get this in my apache logs :
PHP Warning:  Unknown(): A session is active. You cannot change the
session module's ini settings at this time. in Unknown on line
1919973221

And after this i must restart the web server ...

------------------------------------------------------------------------

[2003-12-08 14:29:29] jsnajdr at kerio dot com

I am experiencing this bug too and I think I found its cause. It can
occur when PHP is used in a multithreaded program - I embed PHP
interpreter in my own multithreaded server using a custom SAPI module,
original submitter of this bug uses ISAPI module, which is also
multithreaded.

The 'Session is active' warning is generated by the
PHP_INI_MH(OnUpdateSaveHandler) function that checks
PS(session_status), i.e. the session module globals structure. This
handler is also called when calling TSRMLS_FETCH() (which is a define
for ts_resource_ex() call) before executing a PHP script. See this call
stack from gdb:

#0  OnUpdateSaveHandler (entry=0xb303890, new_value=0x8700f48 "files",
new_value_length=5, mh_arg1=0x0, mh_arg2=0x0, mh_arg3=0x0, stage=1,
tsrm_ls=0xb2dce18)
    at /root/src/php-4.3.4/ext/session/session.c:93
#1  0x0865414c in zend_ini_refresh_cache (p=0xb303890, stage=1,
tsrm_ls=0xb2dce18) at /root/src/php-4.3.4/Zend/zend_ini.c:177
#2  0x0865006f in zend_hash_apply_with_argument (ht=0xb300ac8,
apply_func=0x8654124 <zend_ini_refresh_cache>, argument=0x1,
tsrm_ls=0xb2dce18)
    at /root/src/php-4.3.4/Zend/zend_hash.c:717
#3  0x0865417d in zend_ini_refresh_caches (stage=1, tsrm_ls=0xb2dce18)
at /root/src/php-4.3.4/Zend/zend_ini.c:185
#4  0x08653f88 in zend_copy_ini_directives (tsrm_ls=0xb2dce18) at
/root/src/php-4.3.4/Zend/zend_ini.c:104
#5  0x0864b574 in zend_new_thread_end_handler (thread_id=4423709,
tsrm_ls=0xb2dce18) at /root/src/php-4.3.4/Zend/zend.c:374
#6  0x0862724f in allocate_new_resource
(thread_resources_ptr=0xabac72c, thread_id=4423709) at
/root/src/php-4.3.4/TSRM/TSRM.c:282
#7  0x08627305 in ts_resource_ex (id=0, th_id=0x0) at
/root/src/php-4.3.4/TSRM/TSRM.c:341 

But this handler reads unitialized memory in the new thread's
ps_globals - the TSRM resource has NULL constructor and TSRMLS_FETCH is
called before php_request_startup(), where all the modules are
activated and where the PHP_RINIT_FUNCTION(session) is called to
construct the structure.

Solution: the ps_globals resource must have a non-null constructor
registered in ts_allocate_resource() call in ext/session/session.c

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/26005

-- 
Edit this bug report at http://bugs.php.net/?id=26005&edit=1


Thread (32 messages)

« previous php.bugs (#55366) next »