Skip to content

Commit 6178d25

Browse files
misc/cgo/testsanitizers: accept compilers that don't report location
It appears that GCC before version 10 doesn't report file/line location for asan errors. Change-Id: I03ee24180ba365636596aa2384961df7ce6ed71f Reviewed-on: https://go-review.googlesource.com/c/go/+/374874 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent 8a306e2 commit 6178d25

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

misc/cgo/testsanitizers/asan_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ func TestASAN(t *testing.T) {
6363
// symbolizer program and can't find it.
6464
const noSymbolizer = "external symbolizer"
6565
// Check if -asan option can correctly print where the error occured.
66-
if tc.errorLocation != "" && !strings.Contains(out, tc.errorLocation) && !strings.Contains(out, noSymbolizer) {
66+
if tc.errorLocation != "" &&
67+
!strings.Contains(out, tc.errorLocation) &&
68+
!strings.Contains(out, noSymbolizer) &&
69+
compilerSupportsLocation() {
70+
6771
t.Errorf("%#q exited without expected location of the error\n%s; got failure\n%s", strings.Join(cmd.Args, " "), tc.errorLocation, out)
6872
}
6973
return

misc/cgo/testsanitizers/cc_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,23 @@ func compilerVersion() (version, error) {
218218
return compiler.version, compiler.err
219219
}
220220

221+
// compilerSupportsLocation reports whether the compiler should be
222+
// able to provide file/line information in backtraces.
223+
func compilerSupportsLocation() bool {
224+
compiler, err := compilerVersion()
225+
if err != nil {
226+
return false
227+
}
228+
switch compiler.name {
229+
case "gcc":
230+
return compiler.major >= 10
231+
case "clang":
232+
return true
233+
default:
234+
return false
235+
}
236+
}
237+
221238
type compilerCheck struct {
222239
once sync.Once
223240
err error

0 commit comments

Comments
 (0)