Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix perl_exec_simple memory leak #3403

Merged
merged 1 commit into from
Jun 3, 2024
Merged

Fix perl_exec_simple memory leak #3403

merged 1 commit into from
Jun 3, 2024

Conversation

p120ph37
Copy link
Contributor

Summary

Fix a memory leak in the perl module that can accumulate OS malloc'd memory over time. The leak is fairly slow, so unless your configuration makes very heavy use of perl functions, it may go unnoticed for quite a while, but it can eventually result in OS memory exhaustion and the OOM-killer.

Details

perl_exec_simple has a memory leak because call_argv doesn't garbage-collect its arguments properly. This is technically a Perl bug, and is tracked here: Perl/perl5#22255 But, until it is fixed in Perl, we should work around the issue from the OpenSIPS side.

See #3402 for more details on how to reproduce the bug in OpenSIPS and how to validate the fix.

Solution

This PR fixes the problem by applying the appropriate Perl garbage-collection context markers around the function call so that garbage collection of the arguments happens as control returns to the caller.

Compatibility

No functional change to OpenSIPS.

Closing issues

closes #3402

@liviuchircu liviuchircu self-assigned this Jun 3, 2024
@liviuchircu
Copy link
Member

Hi @p120ph37! I took a quick look at the push_scope(), pop_scope() internals, coupled w/ Perl_savetmps() and Perl_free_tmps() and they seem to be quite harmless - if adding this scope management fixes the leak for you, I am more than happy to merge & backport all the way down to 3.2. Cheers!

@liviuchircu liviuchircu merged commit 6fe6e96 into OpenSIPS:3.4 Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants