mirror of
https://github.com/golang/go
synced 2024-11-18 06:14:46 -07:00
880a689124
The runtime is not instrumented, but the calls to msanread in the runtime can sometimes refer to the system stack. An example is the call to copy in stkbucket in mprof.go. Depending on what C code has done, the system stack may appear uninitialized to msan. Change-Id: Ic21705b9ac504ae5cf7601a59189302f072e7db1 Reviewed-on: https://go-review.googlesource.com/16660 Reviewed-by: David Crawshaw <crawshaw@golang.org>
71 lines
1.7 KiB
Bash
Executable File
71 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Copyright 2015 The Go Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style
|
|
# license that can be found in the LICENSE file.
|
|
|
|
# This directory is intended to test the use of Go with sanitizers
|
|
# like msan, asan, etc. See https://github.com/google/sanitizers .
|
|
|
|
set -e
|
|
|
|
# The sanitizers were originally developed with clang, so prefer it.
|
|
CC=cc
|
|
if test -x "$(type -p clang)"; then
|
|
CC=clang
|
|
fi
|
|
export CC
|
|
|
|
TMPDIR=${TMPDIR:-/tmp}
|
|
echo > ${TMPDIR}/testsanitizers$$.c
|
|
if $CC -fsanitize=memory -c ${TMPDIR}/testsanitizers$$.c -o ${TMPDIR}/testsanitizers$$.o 2>&1 | grep "unrecognized" >& /dev/null; then
|
|
echo "skipping msan test: -fsanitize=memory not supported"
|
|
rm -f ${TMPDIR}/testsanitizers$$.*
|
|
exit 0
|
|
fi
|
|
rm -f ${TMPDIR}/testsanitizers$$.*
|
|
|
|
# The memory sanitizer in versions of clang before 3.6 don't work with Go.
|
|
if $CC --version | grep clang >& /dev/null; then
|
|
ver=$($CC --version | sed -e 's/.* version \([0-9.-]*\).*/\1/')
|
|
major=$(echo $ver | sed -e 's/\([0-9]*\).*/\1/')
|
|
minor=$(echo $ver | sed -e 's/[0-9]*\.\([0-9]*\).*/\1/')
|
|
if test $major -lt 3 || test $major -eq 3 -a $minor -lt 6; then
|
|
echo "skipping msan test; clang version $major.$minor older than 3.6"
|
|
exit 0
|
|
fi
|
|
fi
|
|
|
|
status=0
|
|
|
|
if ! go build -msan std; then
|
|
echo "FAIL: build -msan std"
|
|
status=1
|
|
fi
|
|
|
|
if ! go run -msan msan.go; then
|
|
echo "FAIL: msan"
|
|
status=1
|
|
fi
|
|
|
|
if ! go run -msan msan2.go; then
|
|
echo "FAIL: msan2"
|
|
status=1
|
|
fi
|
|
|
|
if ! go run -msan msan3.go; then
|
|
echo "FAIL: msan3"
|
|
status=1
|
|
fi
|
|
|
|
if ! go run -msan msan4.go; then
|
|
echo "FAIL: msan4"
|
|
status=1
|
|
fi
|
|
|
|
if go run -msan msan_fail.go 2>/dev/null; then
|
|
echo "FAIL: msan_fail"
|
|
status=1
|
|
fi
|
|
|
|
exit $status
|