I posted this in the PHP-dev mailing list, but it appeared to me that the question is more relevant to the apache-dev mailing list. I am reposting it here. Any help would be greatly appreciated.
-------------------- One further piece of information: We can cleanly shutdown Apache 2.0 running the same PHP binaries without any issues. I just now confirmed that with Apache 2.0, the thread which is calling bc_new_num() is the *same* as the thread which calls bc_free_num(). bc_new_num() gets called 3 times by the *same* thread at PHP load time and gets called 3 times by the *same* thread at PHP unload time. This means that there must be way someway to "instruct" Apache 1.3 to use the same thread for all related activities. Thanks, S.R. Ramesh Shankar wrote: As you may know, we are working to things lined up for the Oct 3 demo. We have run into a problem with shutting down Apache which is running PHP. I have provided the details from my posting on the PHP news group below. Any help you can offer in solving this issue would be greatly appreciated: ---------------------------- News posting ------------------------------ I am trying to port PHP and I am running into a problem with Apache 1.3. I am not familiar with the PHP language by itself and I am used to working at the O.S. level and so any help would be greatly appreciated. I tried to read through archives, the readmes, FAQs etc, but I couldn't find answer for this question: When PHP is loaded with Apache 1.3 and Apache is shutdown, PHP 4.2.2 crashes inside the routine _efree() called from bc_free_num(). I found the problem to be related to linked list corruption and on further investigation, suspected it to be a case of the thread calling bc_free_num() to be different from that of the thread that called bc_new_num(). I verfied this by enabling TSRM_DEBUG while building zend, which enables this detection in _efree(). I also set the tsrm_error_level to TSRM_ERROR_LEVEL_ERROR to enable dispalying of TSRM messages to the screen. And sure enough, I got an error message from _efree() from the following excerpt: #if defined(ZTS) && TSRM_DEBUG if (p->thread_id != tsrm_thread_id()) { tsrm_error(TSRM_ERROR_LEVEL_ERROR, "Memory block allocated at %s:(%d) on thread %x freed at %s:(%d) on thread %x, ignoring", p->filename, p->lineno, p->thread_id, __zend_filename, __zend_lineno, tsrm_thread_id()); return; } #endif I have ZTS defined thread support in Zend. I am not able to understand and appreciate all the details of the use of the macros to access the globals variables via AG(), CG() etc and from what I could figure out, ts_resource_ex()is some kind of thread specific data mechanism and would work only if threads are dedicated to PHP. I am not able to understand who is responsible for ensuring that the same thread gets used for a complete request - whether it is some thing that I need to do in Apache or whether I need to enable/disable something while compiling PHP. Any help would be greatly appreciated. Please copy me on your reply as well. Thanks in advance, S.R.