Opened 16 years ago

Closed 16 years ago

#688 closed defect (fixed)

Memory leak on Solaris with pjlib's mutex (thanks Andrey Kobtsev for the fix)

Reported by: bennylp Owned by: bennylp
Priority: normal Milestone: release-1.0.1
Component: pjlib Version: trunk
Keywords: Cc:
Backport to 1.x milestone: Backported:

Description (last modified by bennylp)

Quoting Andrey's mail:

"I've ported the pjproject-1.0-rc4 to Solaris 10. I've discovered the memory leak at solaris2.10. It's interesting that the same code works OK at Linux. I investigated the tests for pjlib and increased the amount of pjlib tests to detect the problem. Because the memory leak is very small on original test suite.

It took the significant time to understand that memory leak relates to the mutex operations. So at the end I detected the problem.

The root cause is absence of pthread_mutexattr_destroy(&attr) call for initialized mutex attribute (pthread_mutexattr_t attr) in init_mutex function in os_core_unix.c. But POSIX Thread API demands it. Because it's PAIR CALL for pthread_mutexattr_init(&attr) (initialize/destroy approach). Each initialize call should be closed with destroy call for given mitex attribute variable.

So each time when pjsip mutex is created we have handle leak for mutex attribute inside OS.

We know that POSIX Thread API implementation is different on Linux & Solaris.

That's why we do not detect pjsip memory leaks under Linux. I think mutex attribute creation/destroying implementation does not use system handle needed to be destroyed."

Change History (3)

comment:1 Changed 16 years ago by bennylp

  • Description modified (diff)

comment:2 Changed 16 years ago by bennylp

  • Description modified (diff)

comment:3 Changed 16 years ago by bennylp

  • Resolution set to fixed
  • Status changed from new to closed

Fixed on r2395. Thanks Andrey Kobtsev for the fix.

Note: See TracTickets for help on using tickets.