From: [EMAIL PROTECTED] Operating system: Windows 2000 PHP version: 4.3.0RC1 PHP Bug Type: BC math related Bug description: BC Math is not Thread Safe, but is in Win32 TS distribution
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 bug report at http://bugs.php.net/?id=20495&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20495&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20495&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20495&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20495&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20495&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20495&r=support Expected behavior: http://bugs.php.net/fix.php?id=20495&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20495&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20495&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20495&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20495&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20495&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20495&r=isapi
