Skip to content

Conversation

@shinrich
Copy link
Member

@shinrich shinrich commented Nov 26, 2019

This PR addresses issue #5777.

After talking with @traeak a few days ago, staring at the code for a day, and talking with @SolidWallOfCode, I think I understand what is going on. The problem is that we are treating ProxyMutex objects as referenced counted smart pointers from within the INKContInternal objects, but we are also treating them as not-smart pointers via the C Plugin interface TSMutexCreate, TSMutexLock, TSMutexUnlock, and TSMutexDestroy.

@traeak identified the commit from PR #4926 as the cause of the leak. That PR was cleaning up the various mutex lock/unlock methods and added refcount increment decrement to TSMutexCreate/Destroy to try to make things uniformly reference counted. However, with that change, the ProxyMutex's created by TSMutexCreate and passed to TSContCreate would never be deleted, because the stand-alone TSMutexDestroy was never called to decrement the last reference count.

This PR

This is not the optimal solution, but good enough for release 9. A more consistent solution would likely require more changes in plugin code. I will leave discussion for that to another thread.

@shinrich shinrich added the Core label Nov 26, 2019
@shinrich shinrich added this to the 10.0.0 milestone Nov 26, 2019
@shinrich shinrich self-assigned this Nov 26, 2019
Copy link
Contributor

@traeak traeak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran a battery of tests against this fix including tests with the slice plugin and remap_stats plugin. The fixes look good and consistent. I think I may have found a leak in remap_stats :(

Copy link
Contributor

@calavera calavera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ran our plugin with this, and I don't see any leak.

@scw00 scw00 requested a review from oknet November 27, 2019 02:14
Copy link
Member

@oknet oknet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good.

It just pulls back the non-smart pointer versions of Mutex_lock, Mutex_unlock, and Mutex_trylock which are used in InkAPI.

@zwoop
Copy link
Contributor

zwoop commented Dec 10, 2019

Cherry-picked to v9.0.x branch.

@zwoop zwoop modified the milestones: 10.0.0, 9.0.0 Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants