ID: 40858 Updated by: [EMAIL PROTECTED] Reported By: scottmacvicar at ntlworld dot com -Status: Assigned +Status: Feedback Bug Type: GD related Operating System: RHEL 4 PHP Version: 5.2.1 Assigned To: pajoye New Comment:
"Moving the code to PHP_MINIT fixes the problem for PHP but the threading options of GD doesn't extend itself to this setup since the function to create the mutex can be called more than once in a short period of time." Do you mean for libGD itself used a library in a random project? If yes, a solution is very similar to this one. We have to do it at load time (like DLLMain on windows). Many other libraries (and many related to FT2, with ft2 cache or their own) rely on this solution. We can give it a try, at least. "I've got a patch that implements the PHP solution running on our boxes, I can provide it if interested." You can always post it, I still did not get the time to do it, so any help is welcome. Previous Comments: ------------------------------------------------------------------------ [2007-03-21 00:40:40] scottmacvicar at ntlworld dot com Moving the code to PHP_MINIT fixes the problem for PHP but the threading options of GD doesn't extend itself to this setup since the function to create the mutex can be called more than once in a short period of time. This small race condition could be fixed by using pthread_once to ensure the mutexes are allocated only once but I'm unsure of the Win32 equivalent. I've got a patch that implements the PHP solution running on our boxes, I can provide it if interested. ------------------------------------------------------------------------ [2007-03-19 19:27:31] [EMAIL PROTECTED] Did we not put it inside in the latest version of the last patch? I do not have the code at hand but as far as I remember Nuno updated it. I will check again tonight. ------------------------------------------------------------------------ [2007-03-19 19:24:54] [EMAIL PROTECTED] >The first problem looks weird. It defeats the whole purpose of the mutex. The !=NULL check is out of the mutex protected block. ------------------------------------------------------------------------ [2007-03-19 19:22:00] [EMAIL PROTECTED] Yes, we noticed the cacheSetup problem too. One solution is to initialize it in MINIT and destroy it in MSHUTDOWN. I'm working on patch to implement this solution. The first problem looks weird. It defeats the whole purpose of the mutex. I do not have the time now to test. I will give it a try later this week. ------------------------------------------------------------------------ [2007-03-19 19:13:02] scottmacvicar at ntlworld dot com I should have mentioned, the first patch deals with the segfault so it errors out gracefully. We've got this running on production now. The second patch is an attempt to deal with the race condition that's still present, would probably be simplier to just to call gdFontCacheSetup() again but I'm unsure what the behaviour is of setting up a mutex thats already initialised and then locking it. ------------------------------------------------------------------------ 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/40858 -- Edit this bug report at http://bugs.php.net/?id=40858&edit=1