ID: 20495 User updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] -Status: Open +Status: Closed Bug Type: BC math related Operating System: Windows 2000 PHP Version: 4.3.0RC1 New Comment:
Fixed in CVS for 4.3.0RC2. Previous Comments: ------------------------------------------------------------------------ [2002-11-19 09:14:10] [EMAIL PROTECTED] I'm adding this bug report to make sure it doesn't get lost. I would ask that this be marked critial for 4.3.0 release. The current thread safe Win32 build is _not_ thread safe because it includes BC Math as a built-in extension, but BC Math is not thread safe. Here is what I said on the php-dev list: > > I'm seeing a memory overrun under PHP 4.3.0pre2 (debug) running under > > Windows 2000 ISAPI. [ . . . ] > > --------------------------------------- > > C:\Work\php-source\php-4.3.0pre2\ext\bcmath\libbcmath\src\init.c(72): > > Freeing 0x01B85050 (1 bytes), script=c:\inetpub\wwwroot\test.php > > Last leak repeated 2 times > > C:\Work\php-source\php-4.3.0pre2\ext\bcmath\libbcmath\src\init.c(57): > > Freeing 0x01B84FF8 (29 bytes), script=c:\inetpub\wwwroot\test.php > > Last leak repeated 2 times > >Based on seeing these leaks I disabled BCMath and recompiled PHP. >Without BCMath active I do not have any of the memory overruns that I >reported in my previous message. > >Looking in the CVS logs for php4/ext/bcmath/bcmath.c I believe there >may be an issue with the changes introduced in version 1.37 (by Andi, >who is CCed also). This patch moved the allocation and freeing of the >static BC numbers _zero_, _one_, and _two_ to a per-request basis >instead of at module initilzation and shutdown. It looks like the >storage locations for those values are global externs, however, which >multiple threads are now allocating and deallocating at the same time. > >Is there somewhere that I'm not understanding in the code that would >keep multiple threads from smashing each other here? And these were Andi's responses: > > You are right. I screwed up. I have to make these TSRM globals. > > I'll try and do it tomorrow. > > Adding a BCMATH_G() TSRM macro around all instances of _one_, _two_ and > _zero_ seems to be quite a pain because it means that libbcmath needs to > understand TSRM now. > On the other hand these three variables need to be per-request because > emalloc()'ed memory can't survive in between requests. > Does anyone have any interesting solutions? If not I guess we can start > hacking at the libbcmath sources. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=20495&edit=1