[Lldb-commits] [lldb] cdae6d7 - [lldb] Fix one leak in reproducer
Fangrui Song via lldb-commits
lldb-commits at lists.llvm.org
Mon Apr 19 19:39:15 PDT 2021
Author: Fangrui Song
Date: 2021-04-19T19:39:10-07:00
New Revision: cdae6d7711d621c19623ae4fbfdde9e0301260c7
URL: https://github.com/llvm/llvm-project/commit/cdae6d7711d621c19623ae4fbfdde9e0301260c7
DIFF: https://github.com/llvm/llvm-project/commit/cdae6d7711d621c19623ae4fbfdde9e0301260c7.diff
LOG: [lldb] Fix one leak in reproducer
Use a variable of static storage duration to reference an intentionally
leaked variable. A static data area is in the GC-set of various leak
checkers.
This fixes 3 `check-lldb-shell` tests in a `-DLLVM_USE_SANITIZER={Leaks,Address}` build,
e.g. `test/Shell/Reproducer/TestHomeDir.test`
Differential Revision: https://reviews.llvm.org/D100806
Added:
Modified:
lldb/tools/driver/Driver.cpp
Removed:
################################################################################
diff --git a/lldb/tools/driver/Driver.cpp b/lldb/tools/driver/Driver.cpp
index e4a60127b65ed..c5121538741f8 100644
--- a/lldb/tools/driver/Driver.cpp
+++ b/lldb/tools/driver/Driver.cpp
@@ -784,8 +784,8 @@ static void printHelp(LLDBOptTable &table, llvm::StringRef tool_name) {
llvm::outs() << examples << '\n';
}
-llvm::Optional<int> InitializeReproducer(llvm::StringRef argv0,
- opt::InputArgList &input_args) {
+static llvm::Optional<int> InitializeReproducer(llvm::StringRef argv0,
+ opt::InputArgList &input_args) {
if (auto *finalize_path = input_args.getLastArg(OPT_reproducer_finalize)) {
if (const char *error = SBReproducer::Finalize(finalize_path->getValue())) {
WithColor::error() << "reproducer finalization failed: " << error << '\n';
@@ -853,8 +853,7 @@ llvm::Optional<int> InitializeReproducer(llvm::StringRef argv0,
// Register the reproducer signal handler.
if (!input_args.hasArg(OPT_no_generate_on_signal)) {
if (const char *reproducer_path = SBReproducer::GetPath()) {
- // Leaking the string on purpose.
- std::string *finalize_cmd = new std::string(argv0);
+ static std::string *finalize_cmd = new std::string(argv0);
finalize_cmd->append(" --reproducer-finalize '");
finalize_cmd->append(reproducer_path);
finalize_cmd->append("'");
More information about the lldb-commits
mailing list