[Lldb-commits] [lldb] 0157a74 - [lldb] Fix an asan error from 27df2d9f556c
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Jan 22 01:15:14 PST 2020
Author: Pavel Labath
Date: 2020-01-22T10:14:47+01:00
New Revision: 0157a74bec3d2ef1fac5b874327b97d2ae8e95c8
URL: https://github.com/llvm/llvm-project/commit/0157a74bec3d2ef1fac5b874327b97d2ae8e95c8
DIFF: https://github.com/llvm/llvm-project/commit/0157a74bec3d2ef1fac5b874327b97d2ae8e95c8.diff
LOG: [lldb] Fix an asan error from 27df2d9f556c
This error is caused by a combination of a couple of factors:
- the test accidentally creating a list with a single (empty) FileSpec
instead of an empty list
- lldb overzeleously converting empty strings into nullptrs
- asan overzeleously validating symlink(2) arguments (the real symlink
call would just fail with EFAULT)
I fix this by using FileSpec::GetPath instead of GetCString. This avoids
the nullptr and also avoids inserting the path into the global string
pool.
I also enhance the test case to test both empty paths and empty lists.
Added:
Modified:
lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
lldb/source/Host/posix/FileSystemPosix.cpp
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
index 006c0bff0838..7735bdaf459c 100644
--- a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/comp_dir_symlink/TestCompDirSymLink.py
@@ -46,6 +46,18 @@ def test_symlink_paths_set_procselfcwd(self):
@skipIf(hostoslist=["windows"])
def test_symlink_paths_unset(self):
+ pwd_symlink = self.create_src_symlink()
+ self.doBuild(pwd_symlink, None)
+ src_path = self.getBuildArtifact(_SRC_FILE)
+ self.assertRaises(
+ AssertionError,
+ lldbutil.run_break_set_by_file_and_line,
+ self,
+ src_path,
+ self.line)
+
+ @skipIf(hostoslist=["windows"])
+ def test_symlink_paths_empty(self):
pwd_symlink = self.create_src_symlink()
self.doBuild(pwd_symlink, "")
src_path = self.getBuildArtifact(_SRC_FILE)
@@ -67,9 +79,11 @@ def create_src_symlink(self):
def doBuild(self, pwd_symlink, setting_value):
self.build(None, None, {'PWD': pwd_symlink})
- self.runCmd(
- "settings set %s '%s'" %
- (_COMP_DIR_SYM_LINK_PROP, setting_value))
+ if setting_value:
+ cmd = "settings set %s '%s'" % (_COMP_DIR_SYM_LINK_PROP, setting_value)
+ else:
+ cmd = "settings clear %s"%_COMP_DIR_SYM_LINK_PROP
+ self.runCmd(cmd)
exe = self.getBuildArtifact(_EXE_NAME)
self.runCmd('file ' + exe, CURRENT_EXECUTABLE_SET)
diff --git a/lldb/source/Host/posix/FileSystemPosix.cpp b/lldb/source/Host/posix/FileSystemPosix.cpp
index 32fae68abb4d..30bf9a51eb67 100644
--- a/lldb/source/Host/posix/FileSystemPosix.cpp
+++ b/lldb/source/Host/posix/FileSystemPosix.cpp
@@ -43,7 +43,7 @@ Status FileSystem::Symlink(const FileSpec &src, const FileSpec &dst) {
Status FileSystem::Readlink(const FileSpec &src, FileSpec &dst) {
Status error;
char buf[PATH_MAX];
- ssize_t count = ::readlink(src.GetCString(), buf, sizeof(buf) - 1);
+ ssize_t count = ::readlink(src.GetPath().c_str(), buf, sizeof(buf) - 1);
if (count < 0)
error.SetErrorToErrno();
else {
More information about the lldb-commits
mailing list