Skip to content

Commit

Permalink
opt: eliminate race test errors (#545)
Browse files Browse the repository at this point in the history
  • Loading branch information
AsterDY committed Nov 7, 2023
1 parent b84e227 commit ba39bc4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/compatibility_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
${{ runner.os }}-go-
- name: main
run: GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic
run: GOMAXPROCS=4 go test -v -gcflags="all=-l" -race github.com/bytedance/sonic

- name: ast
run: GOMAXPROCS=4 go test -v -race github.com/bytedance/sonic/ast
run: GOMAXPROCS=4 go test -v -gcflags="all=-l" -race github.com/bytedance/sonic/ast

- name: qemu
run: sh scripts/qemu.sh
3 changes: 2 additions & 1 deletion internal/rt/fastmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ func FuncAddr(f interface{}) unsafe.Pointer {
}
}

//go:nocheckptr
func IndexChar(src string, index int) unsafe.Pointer {
return unsafe.Pointer(uintptr((*GoString)(unsafe.Pointer(&src)).Ptr) + uintptr(index))
}

//go:nocheckptr
func IndexByte(ptr []byte, index int) unsafe.Pointer {
return unsafe.Pointer(uintptr((*GoSlice)(unsafe.Pointer(&ptr)).Ptr) + uintptr(index))
}

//go:nosplit
func GuardSlice(buf *[]byte, n int) {
c := cap(*buf)
l := len(*buf)
Expand Down

0 comments on commit ba39bc4

Please sign in to comment.