[Bro-Dev] Help Troubleshooting a Perftools Memleak
Robin Sommer
robin at icir.org
Wed Oct 29 20:35:12 PDT 2014
On Wed, Oct 29, 2014 at 16:48 -0400, you wrote:
> Digging a little deeper shows that two of these leaks are in RE_parse
> (re-parse.y:110 and re-parse.y:133), one is in re__scan_buffer
> (re-scan.cc:2035), and one is in re__scan_bytes (re-scan.cc::2084).
I'm pretty sure I know where that's coming from: normally regexp
compilation is happening before Bro's main loop, and hence not
accounted for by the leak checking. BinPAC however delays
initialization until the first time it tries to match something.
Unfortunately the obvious fix doesn't work. I'm pasting it in below,
but that change lets Bro crash because it now depends on the order in
which global constructors run. If anybody has a better idea, let me
know.
Robin
diff --git a/lib/binpac_regex.h b/lib/binpac_regex.h
index b41e6db..7acc2c6 100644
--- a/lib/binpac_regex.h
+++ b/lib/binpac_regex.h
@@ -14,7 +14,8 @@ public:
RegExMatcher(const char *pattern)
: pattern_(pattern)
{
- re_matcher_ = 0;
+ re_matcher_ = new RE_Matcher(pattern_.c_str());
+ re_matcher_->Compile();
}
~RegExMatcher()
@@ -25,11 +26,6 @@ public:
// Returns the length of longest match, or -1 on mismatch.
int MatchPrefix(const_byteptr data, int len)
{
- if ( ! re_matcher_ )
- {
- re_matcher_ = new RE_Matcher(pattern_.c_str());
- re_matcher_->Compile();
- }
return re_matcher_->MatchPrefix(data, len);
}
--
Robin Sommer * ICSI/LBNL * robin at icir.org * www.icir.org/robin
More information about the bro-dev
mailing list