symisc / PH7

An Embedded Implementation of PHP (C Library)
http://ph7.symisc.net
Other
493 stars 68 forks source link

mutex memory leak in ph7_vm_release (with patch) #8

Open tarkin000 opened 9 years ago

tarkin000 commented 9 years ago

Latest clone, on Debian 7 i686 (x32), gcc 4.7.2 (Debian 4.7.2-5) -DPH7_ENABLE_MATH_FUNC -DPH7_ENABLE_THREADS

Valgrind reports a definite memory loss of 112 bytes. The loss starts when a recursive mutex is created in ProcessScript (60601). When ph7_vm_release is called, the mutex is not released.

This patch fixes that.

---------8<-----------------------------------8<---------------------------------------------8<--------------------------
--- ph7.oem 2015-03-15 11:58:17.430116368 -0400
+++ ph7.c 2015-03-15 11:55:36.150961417 -0400
@@ -60873,6 +60873,8 @@
 #if defined(PH7_ENABLE_THREADS)
   /* Leave VM mutex */
   SyMutexLeave(sMPGlobal.pMutexMethods,pVm->pMutex); /* NO-OP if sMPGlobal.nThreadingLevel != PH7_THREAD_LEVEL_MULTI */
+  /* free VM mutex PATCH by SGM 15-MAR-2015 */
+  SyMutexRelease(sMPGlobal.pMutexMethods,pVm->pMutex);
 #endif
  if( rc == PH7_OK ){
    /* Unlink from the list of active VM */
----------------------------->8------------------------->8-------------------------------------->8-----------------------

Hope this helps.

symisc commented 9 years ago

All right, Thx!