ModSecurity: Memory leaks with nginx reload (without restart)
When, instead of restarting nginx, one performs a reload
of the configuration, memory may leak.
The memory leaks are not large per reload, but if doing so frequently, the free memory reduction will become noticeable. A near-term mitigation is to at least periodically do a true restart.
This issue is being created in lieu of #2502 and others.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 18 (7 by maintainers)
I have identified some leaks when using the
--with-lmdb
option. I will be addressing those shortly.[Edit: the issue mentioned here was resolved in #2983 . Note that those leaks are not restricted to rule reload but can occur during each transaction.]
Hey @martinhsv, modsec library has been built with
./configure --with-pcre2
so PCRE2.Thanks to all for the ongoing reports
@GNU-Plus-Windows-User : thanks for the specific reference to
@pmFromFile
.Interestingly, the suspect functionality seems to have already been noted quite some time ago: https://github.com/SpiderLabs/ModSecurity/blame/b84f32d6f2e2e024cd85d82c6707ce66327eb7d0/src/utils/acmp.cc#L32
… but it had not previously come to my attention.
I can also confirm the memory leak on reload still exists. personally, I’ve found the memory leak size is based on the number of
modsecurity on;
andmodsecurity_rules_file /path/to/example.conf;
directives and the use of@pmFromFile
.Known memory leaks of general application that occur when executing nginx reload have been resolved as of v3.0.9.
I will, however, leave this item open for at least a few weeks to allow for any additional reports.
It is probable that any further memory leaks associated with reload are related to less-commonly used features. Specific information about what sorts of Sec* constructs appear to trigger the effect would be helpful.
Thanks for the response. I think we may have a temporary fix that allows us to point to the specific commit that includes the memory leak fix. 8-10 weeks is not bad at all assuming our fix works for the time being.