Skip to content

Commit ac6dffd

Browse files
ylnJulian Lettner
and
Julian Lettner
authored
[Sanitizer] Disable inlining to improve robustness of test (swiftlang#33753)
This test checks that Sanitizer reports contain properly symbolicated stacks. Let's make sure that all of the expected frames appear in the stack by disabling inlining and preventing tail call optimization. rdar://68171463 Co-authored-by: Julian Lettner <[email protected]>
1 parent 27f453c commit ac6dffd

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

test/Sanitizers/symbolication-linux.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,25 @@
1111
// symbolication. Note that `llvm-symbolizer` does not demangle Swift symbol
1212
// names, so we use `swift demangle`.
1313

14+
@inline(never)
1415
func foo() {
1516
let x = UnsafeMutablePointer<Int>.allocate(capacity: 1)
1617
x.deallocate()
1718
print(x.pointee)
1819
}
1920

21+
@inline(never)
2022
func bar() {
2123
foo()
24+
print("Prevent tail call optimization")
2225
}
2326

2427
bar()
2528

26-
2729
// Out-of-process
28-
// OOP: #0 0x{{[0-9a-f]+}} in main.foo() -> () {{.*}}symbolication-linux.swift:[[@LINE-11]]
30+
// OOP: #0 0x{{[0-9a-f]+}} in main.foo() -> () {{.*}}symbolication-linux.swift:[[@LINE-12]]
2931
// OOP-NEXT: #1 0x{{[0-9a-f]+}} in main.bar() -> () {{.*}}symbolication-linux.swift:[[@LINE-8]]
30-
// OOP-NEXT: #2 0x{{[0-9a-f]+}} in main {{.*}}symbolication-linux.swift:[[@LINE-6]]
32+
// OOP-NEXT: #2 0x{{[0-9a-f]+}} in main {{.*}}symbolication-linux.swift:[[@LINE-5]]
3133

3234
// In-process
3335
// IP: #0 0x{{[0-9a-f]+}} in main.foo() -> ()+0x

test/Sanitizers/symbolication.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,25 @@
99
// both out-of-process (via `atos`) and when falling back to in-process
1010
// symbolication. Note that `atos` also demangles Swift symbol names.
1111

12+
@inline(never)
1213
func foo() {
1314
let x = UnsafeMutablePointer<Int>.allocate(capacity: 1)
1415
x.deallocate()
1516
print(x.pointee)
1617
}
1718

19+
@inline(never)
1820
func bar() {
1921
foo()
22+
print("Prevent tail call optimization")
2023
}
2124

2225
bar()
2326

24-
2527
// Out-of-process
26-
// OOP: #0 0x{{[0-9a-f]+}} in foo() symbolication.swift:[[@LINE-11]]
28+
// OOP: #0 0x{{[0-9a-f]+}} in foo() symbolication.swift:[[@LINE-12]]
2729
// OOP-NEXT: #1 0x{{[0-9a-f]+}} in bar() symbolication.swift:[[@LINE-8]]
28-
// OOP-NEXT: #2 0x{{[0-9a-f]+}} in main symbolication.swift:[[@LINE-6]]
30+
// OOP-NEXT: #2 0x{{[0-9a-f]+}} in main symbolication.swift:[[@LINE-5]]
2931

3032
// In-process
3133
// IP: #0 0x{{[0-9a-f]+}} in main.foo() -> ()+0x

0 commit comments

Comments
 (0)