-
Notifications
You must be signed in to change notification settings - Fork 1.6k
memory leak in msc_rules_add_file / msc_rules_cleanup #2710
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
Comments
As you yourself have pointed out, there already is an issue open for this problem (indeed, more than one). What is your purpose in opening yet another issue for the same problem? From the perspective of issue management, tracking, (as well as for other users to search for), it is almost never advantageous to open duplicate issues. |
Hi @liudongmiao Thanks for the suggestion regarding the memory leak problem. |
@aaishere I have a pr owasp-modsecurity/ModSecurity-nginx#277 |
@martinhsv As previous issue doesn't address the real issue, so I opened a new issue. And finally, make a workaround pr on ModSecurity-nginx. |
@martinhsv The main memory leak is this:
Then, when |
@martinhsv I have make a pr at #2728 |
Hello Liudongmiao, I'm interested to test your patch, but I have limited knowledge of how GIT work. EDIT:: I download every thing from here: I extract and merged the two forlder and recompile the "ngx_http_modsecurity_module.so"
Then restart my Nginx. I will leave it on my test server to see if I have the memory leak. Best regards |
@liudongmiao Hey it seems that I still have my memory leak. May be I do something wrong ? Best regards |
If you don't use patch in #2728, there are still memory leak in ModSecurity. For https://github.com/liudongmiao/ModSecurity-nginx/tree/patch-lazy-load-rules, there are still memory leak. |
Oh ok ! So I did the same thing, take this: Merged the two directory and recompile my "ngx_http_modsecurity_module.so" with it. I'll keep you inform if I still see the memory leak. Best regards |
Hello @liudongmiao, I reproduce the step to recompile my "ngx_http_modsecurity_module.so" with your last patch https://github.com/liudongmiao/ModSecurity/tree/patch-2 Can you confirm me that I do the right thing concerning the compilation of my "ngx_http_modsecurity_module.so" ? Best regards |
@labanana34 Please describe the memory leak types.
|
@liudongmiao I think I have the 2nd, worker process leak. When I look at my HTOP, "nginx: worker process" grow on memory until there is nothing left. Best regards. |
@labanana34 Please email me. |
rule.h needs a virtual ~Rule destructor to fix the rule memory leak. A virtual ~RuleWithAction destructor is not enough. If rule.h does not explicitly define a virtual ~Rule destructor, then the Rule destructor is implicitly non-virtual, so that in rules.h the destruction of vector m_rules does not call the destructors for the Rule subclasses, thereby failing to delete the objects owned by the Rule subclasses. |
It's shared_ptr. In my test, it doesn't require. I will figure it out. (update: explain at #2728 (comment)). |
Would be fixed in #2801, partially. |
Closing as duplicate. |
There are reports on memory leak on
nginx -s reload
, #2381 #2502 #2552 #2636 and many others .Of course, #2580 doesn't solve problems.(Update: #2580 should have fixed this problem.)There is a simple poc:
After run 100 times on CRS rules, the memory grow to 1.2G, about 12M for rules.
Of course, for nginx -s reload, it may be solved by moving
msc_rules_add_file
to working process, then it doesn't affect master process, and sovle the problem.However, IMO, it should be fixed in ModSecurity, as we have shared_ptr in c++11.
The text was updated successfully, but these errors were encountered: