-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add Time based rolling policy fuzzer #461
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Adam Korczynski <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preconditions should be specified in the interface but are not yet being part of the C++ language.
Do you agree that the caller has a responseability to honour preconditions?
tbrp->activateOptions(pool); | ||
rfa->setRollingPolicy(tbrp); | ||
rfa->activateOptions(pool); | ||
rfa->setBufferSize(fdp.ConsumeIntegral<int>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will violate an undocumented but assumed precondition that a buffer of this size can be allocated by the system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. What would a generous but still reasonable max size be here? Could we do 10,000?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest leaving it as a default. A reasonable precondition would say "big enough for a few logging events and not bigger than the system can handle"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the code, it seems that it is not actually allocating the amount of memory as defined by setBufferSize
. It will expand up to the limit:
logging-log4cxx/src/main/cpp/bufferedwriter.cpp
Lines 67 to 83 in da0313e
void BufferedWriter::write(const LogString& str, Pool& p) | |
{ | |
if (m_priv->buf.length() + str.length() > m_priv->sz) | |
{ | |
m_priv->out->write(m_priv->buf, p); | |
m_priv->buf.erase(m_priv->buf.begin(), m_priv->buf.end()); | |
} | |
if (str.length() > m_priv->sz) | |
{ | |
m_priv->out->write(str, p); | |
} | |
else | |
{ | |
m_priv->buf.append(str); | |
} | |
} |
So a random number here probably doesn't hurt, although I don't think it would actually cause any bugs either.
Yes. |
Adds a fuzzer that tests
TimeBasedRollingPolicy->rollover()
.