Skip to content

Commit 41df8ab

Browse files
authored
Merge pull request #5614 from apple/🍒/rebranch/17737437ed7bb4ca646020b17df822865247d193
[dsymutil] Fix assertion in the Reproducer/FileCollector when TMPDIR is empty
2 parents 2eb15f3 + 7752f41 commit 41df8ab

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)