go asan5_fail 源码

  • 2022-07-15
  • 浏览 (1229)

golang asan5_fail 代码

文件路径:/misc/cgo/testsanitizers/testdata/asan5_fail.go

package main

import (
	"fmt"
	"runtime"
	"unsafe"
)

func main() {
	p := new([1024 * 1000]int)
	p[0] = 10
	r := bar(&p[1024*1000-1])
	fmt.Printf("r value is %d", r)
}

func bar(a *int) int {
	p := unsafe.Add(unsafe.Pointer(a), 2*unsafe.Sizeof(int(1)))
	runtime.ASanWrite(p, 8) // BOOM
	*((*int)(p)) = 10
	return *((*int)(p))
}

相关信息

go 源码目录

相关文章

go asan1_fail 源码

go asan2_fail 源码

go asan3_fail 源码

go asan4_fail 源码

go asan_global1_fail 源码

go asan_global2_fail 源码

go asan_global3_fail 源码

go asan_global4_fail 源码

go asan_global5 源码

go asan_unsafe_fail1 源码

0  赞