Skip to content

question: use msc_rules_cleanup not free memory #2636

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

Closed
Brhetty opened this issue Nov 3, 2021 · 3 comments
Closed

question: use msc_rules_cleanup not free memory #2636

Brhetty opened this issue Nov 3, 2021 · 3 comments

Comments

@Brhetty
Copy link

Brhetty commented Nov 3, 2021

hi:
I am just add rule but use msc_rule_cleanup bot free memory. What's wrong with me

modsecurity vserion: v3.0.4

int main()
{
    const char *error;
    const char *rule = "SecRuleEngine On";
    void *rules_set;
    int i = 0;
    int rc;
    rules_set = msc_create_rules_set();
    for(i = 0; i < 100000; i++) {
       rc =  msc_rules_add(rules_set, rule, &error);
       if (rc < 0) {
           printf("error: %s", error);
       }
    }
    msc_rules_cleanup(rules_set);
}
@martinhsv
Copy link
Contributor

Hello @Brhetty ,

I do not understand what exactly you are asking. Would you like to try rephrasing or expanding on your question?

@Brhetty
Copy link
Author

Brhetty commented Nov 10, 2021

Hello @Brhetty ,

I do not understand what exactly you are asking. Would you like to try rephrasing or expanding on your question?

When I use msc_rules_add, it will memory leak.Could you help me?

@martinhsv
Copy link
Contributor

Since you're using a older version of ModSecurity, a normal piece of advice would be to upgrade; there were at least some memory problems fixed between v3.0.4 and v3.0.5.

However, in this case, I assume you are simply triggering previously-reported issues around memory leaks when nginx rule reload is performed without a restart. See for example #2552

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

No branches or pull requests

3 participants
@martinhsv @Brhetty and others