[Lldb-commits] [lldb] afcdd43 - [llvm] [Support] Fix segv if argv0 is null in getMainExecutable()
Michał Górny via lldb-commits
lldb-commits at lists.llvm.org
Mon Nov 9 02:37:04 PST 2020
Author: Michał Górny
Date: 2020-11-09T11:35:11+01:00
New Revision: afcdd43bf71d9503dbd2b700710818daafa0cb00
URL: https://github.com/llvm/llvm-project/commit/afcdd43bf71d9503dbd2b700710818daafa0cb00
DIFF: https://github.com/llvm/llvm-project/commit/afcdd43bf71d9503dbd2b700710818daafa0cb00.diff
LOG: [llvm] [Support] Fix segv if argv0 is null in getMainExecutable()
When LLDB Python bindings are used and stack backtraces are enabled
for logging, getMainExecutable() is called with argv0 being null.
This caused the fallback function getprogpath() (used on FreeBSD, NetBSD
and Linux) to segfault. Make it handle null executable name gracefully.
Differential Revision: https://reviews.llvm.org/D91012
Added:
Modified:
lldb/test/API/commands/log/basic/TestLogging.py
llvm/lib/Support/Unix/Path.inc
Removed:
################################################################################
diff --git a/lldb/test/API/commands/log/basic/TestLogging.py b/lldb/test/API/commands/log/basic/TestLogging.py
index da1a3e8a50cf..4ba67f8794b6 100644
--- a/lldb/test/API/commands/log/basic/TestLogging.py
+++ b/lldb/test/API/commands/log/basic/TestLogging.py
@@ -93,8 +93,6 @@ def test_log_append(self):
# Enable all log options and check that nothing crashes.
@skipIfWindows
- # TODO: figure out why it segfaults
- @skipIfFreeBSD
def test_all_log_options(self):
if (os.path.exists(self.log_file)):
os.remove(self.log_file)
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc
index 27b54610867b..8b1dbdb08a14 100644
--- a/llvm/lib/Support/Unix/Path.inc
+++ b/llvm/lib/Support/Unix/Path.inc
@@ -147,6 +147,9 @@ test_dir(char ret[PATH_MAX], const char *dir, const char *bin)
static char *
getprogpath(char ret[PATH_MAX], const char *bin)
{
+ if (bin == nullptr)
+ return nullptr;
+
/* First approach: absolute path. */
if (bin[0] == '/') {
if (test_dir(ret, "/", bin) == 0)
More information about the lldb-commits
mailing list