runtime: gofmt

libfuzzerHookStrCmp is manually reformatted into a proper go doc list.

We don't always format testdata, but these test programs are standard Go
programs that can be formatted.

Change-Id: I4dde398bca225ae8c72e787e4d43fd0ccfd0a90b
Reviewed-on: https://go-review.googlesource.com/c/go/+/411114
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Michael Pratt 2022-06-08 10:46:42 -04:00 committed by Gopher Robot
parent f330a3a987
commit 3426b7201d
4 changed files with 16 additions and 14 deletions

View File

@ -11,10 +11,10 @@ import "unsafe"
func libfuzzerCallWithTwoByteBuffers(fn, start, end *byte) func libfuzzerCallWithTwoByteBuffers(fn, start, end *byte)
func libfuzzerCallTraceIntCmp(fn *byte, arg0, arg1, fakePC uintptr) func libfuzzerCallTraceIntCmp(fn *byte, arg0, arg1, fakePC uintptr)
func libfuzzerCall4(fn *byte, fakePC uintptr, s1, s2 unsafe.Pointer, result uintptr) func libfuzzerCall4(fn *byte, fakePC uintptr, s1, s2 unsafe.Pointer, result uintptr)
// Keep in sync with the definition of ret_sled in src/runtime/libfuzzer_amd64.s // Keep in sync with the definition of ret_sled in src/runtime/libfuzzer_amd64.s
const retSledSize = 512 const retSledSize = 512
func libfuzzerTraceCmp1(arg0, arg1 uint8, fakePC int) { func libfuzzerTraceCmp1(arg0, arg1 uint8, fakePC int) {
fakePC = fakePC % retSledSize fakePC = fakePC % retSledSize
libfuzzerCallTraceIntCmp(&__sanitizer_cov_trace_cmp1, uintptr(arg0), uintptr(arg1), uintptr(fakePC)) libfuzzerCallTraceIntCmp(&__sanitizer_cov_trace_cmp1, uintptr(arg0), uintptr(arg1), uintptr(fakePC))
@ -71,15 +71,15 @@ func init() {
libfuzzerCallWithTwoByteBuffers(&__sanitizer_cov_pcs_init, &pcTables[0], &pcTables[size-1]) libfuzzerCallWithTwoByteBuffers(&__sanitizer_cov_pcs_init, &pcTables[0], &pcTables[size-1])
} }
// We call libFuzzer's __sanitizer_weak_hook_strcmp function // We call libFuzzer's __sanitizer_weak_hook_strcmp function which takes the
// which takes the following four arguments: // following four arguments:
// 1- caller_pc: location of string comparison call site //
// 2- s1: first string used in the comparison // 1. caller_pc: location of string comparison call site
// 3- s2: second string used in the comparison // 2. s1: first string used in the comparison
// 4- result: an integer representing the comparison result. Libfuzzer only distinguishes between two cases: // 3. s2: second string used in the comparison
// - 0 means that the strings are equal and the comparison will be ignored by libfuzzer. // 4. result: an integer representing the comparison result. 0 indicates
// - Any other value means that strings are not equal and libfuzzer takes the comparison into consideration. // equality (comparison will ignored by libfuzzer), non-zero indicates a
// Here, we pass 1 when the strings are not equal. // difference (comparison will be taken into consideration).
func libfuzzerHookStrCmp(s1, s2 string, fakePC int) { func libfuzzerHookStrCmp(s1, s2 string, fakePC int) {
if s1 != s2 { if s1 != s2 {
libfuzzerCall4(&__sanitizer_weak_hook_strcmp, uintptr(fakePC), cstring(s1), cstring(s2), uintptr(1)) libfuzzerCall4(&__sanitizer_weak_hook_strcmp, uintptr(fakePC), cstring(s1), cstring(s2), uintptr(1))

View File

@ -122,13 +122,13 @@ func NilPanic() {
panic(nil) panic(nil)
} }
type exampleCircleStartError struct {} type exampleCircleStartError struct{}
func (e exampleCircleStartError) Error() string { func (e exampleCircleStartError) Error() string {
panic(exampleCircleEndError{}) panic(exampleCircleEndError{})
} }
type exampleCircleEndError struct {} type exampleCircleEndError struct{}
func (e exampleCircleEndError) Error() string { func (e exampleCircleEndError) Error() string {
panic(exampleCircleStartError{}) panic(exampleCircleStartError{})
@ -136,4 +136,4 @@ func (e exampleCircleEndError) Error() string {
func CircularPanic() { func CircularPanic() {
panic(exampleCircleStartError{}) panic(exampleCircleStartError{})
} }

View File

@ -27,8 +27,8 @@ import "C"
import ( import (
"fmt" "fmt"
"os" "os"
"runtime/pprof"
"runtime" "runtime"
"runtime/pprof"
"time" "time"
) )

View File

@ -11,6 +11,7 @@ package main
import "C" import "C"
// CallMeBack call backs C code. // CallMeBack call backs C code.
//
//export CallMeBack //export CallMeBack
func CallMeBack(callback C.callmeBackFunc) { func CallMeBack(callback C.callmeBackFunc) {
C.bridgeCallback(callback) C.bridgeCallback(callback)
@ -21,6 +22,7 @@ func CallMeBack(callback C.callmeBackFunc) {
// validate that it does not crash the program before another handler could take an action. // validate that it does not crash the program before another handler could take an action.
// The idea here is to reproduce what happens when you attach a debugger to a running program. // The idea here is to reproduce what happens when you attach a debugger to a running program.
// It also simulate the behavior of the .Net debugger, which register its exception/continue handlers lazily. // It also simulate the behavior of the .Net debugger, which register its exception/continue handlers lazily.
//
//export Dummy //export Dummy
func Dummy() int { func Dummy() int {
return 42 return 42