Skip to content

Commit a52bc83

Browse files
TotallyGamerJethajimehoshi
authored andcommitted
internal/fakecgo: disable race in fakecgo (#319)
Closes #318
1 parent 1638563 commit a52bc83

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

.github/workflows/test.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,16 @@ jobs:
129129
sudo apt-get install g++-multilib
130130
env CGO_ENABLED=1 GOARCH=386 go test -shuffle=on -v -count=10 ./...
131131
132-
- name: go test race
132+
- name: go test race (no Cgo)
133+
if: ${{ runner.os == 'macOS' && !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') }}
134+
run: |
135+
# -race usually requires Cgo, but macOS is an exception. See https://go.dev/doc/articles/race_detector#Requirements
136+
env CGO_ENABLED=0 go test -race -shuffle=on -v -count=10 ./...
137+
138+
- name: go test race (Cgo)
133139
if: ${{ !startsWith(matrix.go, '1.18.') && !startsWith(matrix.go, '1.19.') }}
134140
run: |
135-
go test -race -shuffle=on -v -count=10 ./...
141+
env CGO_ENABLED=1 go test -race -shuffle=on -v -count=10 ./...
136142
137143
freebsd:
138144
strategy:

internal/fakecgo/gen.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func call5(fn, a1, a2, a3, a4, a5 uintptr) uintptr
3737
3838
{{ range . -}}
3939
//go:nosplit
40+
//go:norace
4041
func {{.Name}}(
4142
{{- range .Args -}}
4243
{{- if .Name -}}

internal/fakecgo/go_libinit.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var (
1919
)
2020

2121
//go:nosplit
22+
//go:norace
2223
func x_cgo_notify_runtime_init_done() {
2324
pthread_mutex_lock(&runtime_init_mu)
2425
runtime_init_done = 1
@@ -28,6 +29,8 @@ func x_cgo_notify_runtime_init_done() {
2829

2930
// Store the g into a thread-specific value associated with the pthread key pthread_g.
3031
// And pthread_key_destructor will dropm when the thread is exiting.
32+
//
33+
//go:norace
3134
func x_cgo_bindm(g unsafe.Pointer) {
3235
// We assume this will always succeed, otherwise, there might be extra M leaking,
3336
// when a C thread exits after a cgo call.

internal/fakecgo/symbols.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)