Skip to content

Commit 1773743

Browse files
committed
[dsymutil] Fix assertion in the Reproducer/FileCollector when TMPDIR is empty
Fix a assertion in dsymutil coming from the Reproducer/FileCollector. When TMPDIR is empty, the root becomes a relative path, triggering an assertion when adding a relative path to the VFS mapping. This patch fixes the issue by resolving the relative path and also moves the assertion up to make it easier to diagnose these issues in the future. rdar://102170986 Differential revision: https://reviews.llvm.org/D137959
1 parent eb7d16e commit 1773743

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

llvm/lib/Support/FileCollector.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ static bool isCaseSensitivePath(StringRef Path) {
5050
}
5151

5252
FileCollector::FileCollector(std::string Root, std::string OverlayRoot)
53-
: Root(std::move(Root)), OverlayRoot(std::move(OverlayRoot)) {
53+
: Root(Root), OverlayRoot(OverlayRoot) {
54+
assert(sys::path::is_absolute(Root) && "Root not absolute");
55+
assert(sys::path::is_absolute(OverlayRoot) && "OverlayRoot not absolute");
5456
}
5557

5658
void FileCollector::PathCanonicalizer::updateWithRealPath(

llvm/test/tools/dsymutil/X86/reproducer.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ RUN: cp %p/../Inputs/basic3.macho.x86_64.o %t/Inputs
1313
# Verify all the files are present.
1414
RUN: dsymutil -f -o - -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 | llvm-dwarfdump -a - | FileCheck %s
1515

16+
# Make sure we don't crash with an empty TMPDIR.
17+
RUN: env TMPDIR="" dsymutil -o -f -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 2>&1
18+
1619
# Create a reproducer.
1720
RUN: env DSYMUTIL_REPRODUCER_PATH=%t.repro dsymutil -gen-reproducer -f -o %t.generate -oso-prepend-path=%t %t/Inputs/basic.macho.x86_64 2>&1 | FileCheck %s --check-prefixes=REPRODUCER
1821
RUN: llvm-dwarfdump -a %t.generate | FileCheck %s

llvm/tools/dsymutil/Reproducer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static std::string createReproducerDir(std::error_code &EC) {
2020
} else {
2121
EC = sys::fs::createUniqueDirectory("dsymutil", Root);
2222
}
23+
sys::fs::make_absolute(Root);
2324
return EC ? "" : std::string(Root);
2425
}
2526

0 commit comments

Comments
 (0)