-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Double free of object malloc error when running beast::severities::kTrace
#5388
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
You need a mutex in the SuiteJournal class iirc
It is multi threaded writing to a string buffer subclass and flushing all
the time.
I'll send a snippet for "a" fix when on laptop
|
// Only write the string if the level at least equals the threshold.
if (level >= threshold())
{
static std::mutex log_mutex_;
std::lock_guard lock(log_mutex_);
suite_.log << s << partition_ << text << std::endl; // <----- std::endl triggers a flush, iffy with multiple thread
} That's the simplest fix which I used for the jshook emit tests. |
Analysis of Multithreaded Logging Issues in the Rippled CodebaseAfter analyzing the code snippets, I can identify a potential threading issue in the logging system that could lead to a double free situation. Let me walk through the problem step by step. Thread Creation and Logging SetupIn the
The Log Write PathLet's trace the path of a log message:
The Race ConditionThe issue occurs when multiple threads write to the log simultaneously:
The Double Free ProblemThe double free issue happens because:
Additionally, the void runner::log(std::string const& s)
{
std::lock_guard lock(mutex_);
// ...
} But this only protects the runner's state, not the How
|
Uh oh!
There was an error while loading. Please reload this page.
Issue Description
Steps to Reproduce
Run a test with the following env:
test::jtx::Env env{*this, envconfig(), features, nullptr, beast::severities::kTrace};
Expected Result
Actual Result
Environment
Supporting Files
The text was updated successfully, but these errors were encountered: