Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/website: unclear C compiler requirements for race detector on windows #66934

Open
kamalshkeir opened this issue Apr 19, 2024 · 13 comments
Open
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. website
Milestone

Comments

@kamalshkeir
Copy link

Go version

go version go1.22.0 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\kamal\AppData\Local\go-build
set GOENV=C:\Users\kamal\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\kamal\go\pkg\mod
set GONOPROXY=github.com/kamalshkeir/kamal
set GONOSUMDB=github.com/kamalshkeir/kamal
set GOOS=windows
set GOPATH=C:\Users\kamal\go
set GOPRIVATE=github.com/kamalshkeir/kamal
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\kamal\Desktop\testmaps\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\kamal\AppData\Local\Temp\go-build4174937017=/tmp/go-build -gno-record-gcc-switches

What did you do?

import (
	"fmt"
	"testing"
)

func makeRace() {
	var x int
	c := make(chan bool)
	go func() {
		x = 1
		c <- true
	}()
	fmt.Println(x)
	<-c
}

func TestFoo(t *testing.T) {
	makeRace()
}

when running go test ./... -v -race :

PS C:\Users\kamal\Desktop\testmaps> go test ./... -v -race
?       testmaps        [no test files]
exit status 0xc0000139
FAIL    testmaps/cache  0.172s
FAIL

What did you see happen?

also i notice that i have the same exit error even if there is no race at all, just adding the -race flag break everything

What did you expect to see?

since i use -v, i should see logs of where the race happened

@seankhliao
Copy link
Member

That's a windows loader error, I don't think there's anything to do from Go.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2024
@kamalshkeir
Copy link
Author

@seankhliao what do you mean by windows loader ?
why this is not a bug since it was working fine before go1.22 ? (-v should not log informations)
why it doesn't work even if there is no race (was working before go1.22) ?

@kamalshkeir
Copy link
Author

in simple words, -race should detect the race, it doesn't, seems like a bug for me (no matter the os)

@seankhliao
Copy link
Member

If you search for "exit status 0xc0000139", you'll find that it's a windows / c toolchain issue.

@kamalshkeir
Copy link
Author

@seankhliao And ?
Still don't get it sorry :/

So should i change my OS if i want to use go1.22 ? or maybe use go until go1.21 on windows OS ?

@randall77
Copy link
Contributor

I'm going to reopen, but @seankhliao is right, this is likely a C toolchain issue.
See, for example, https://go.dev/doc/articles/race_detector#Requirements and #61916
We're going to need more information.

What windows version are you using?
What C toolchain are you using? Version?
Can you put together a complete reproducer? Complete files and directory structure.

@randall77 randall77 reopened this Apr 20, 2024
@kamalshkeir
Copy link
Author

Thank you @randall77

Here is my go env and the output of the command --print-file-name libsynchronization.a

PS C:\Users\kamal\Desktop\korm> go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\kamal\AppData\Local\go-build
set GOENV=C:\Users\kamal\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\kamal\go\pkg\mod
set GONOPROXY=github.com/kamalshkeir/kamal
set GONOSUMDB=github.com/kamalshkeir/kamal
set GOOS=windows
set GOPATH=C:\Users\kamal\go
set GOPRIVATE=github.com/kamalshkeir/kamal
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\kamal\Desktop\korm\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\kamal\AppData\Local\Temp\go-build3319990875=/tmp/go-build -gno-record-gcc-switches
PS C:\Users\kamal\Desktop\korm> gcc  --print-file-name libsynchronization.a
D:/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/libsynchronization.a

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 20, 2024
@randall77
Copy link
Contributor

randall77 commented Apr 20, 2024

The fact that you have mingw 8.1.0 makes it sound like this might be a dup of #61916. But your program worked fine on 1.21 and not 1.22? In #61916 they reported working on 1.19 but not on 1.21, which is different.
Would be worth trying mingw 11.2.

@kamalshkeir
Copy link
Author

kamalshkeir commented Apr 20, 2024

@randall77 , i try it with go1.20 , works fine, now i will try with mingw 11.2:

PS C:\Users\kamal\Desktop\testwsStream> go mod tidy
PS C:\Users\kamal\Desktop\testwsStream> go test ./... -v -race
exit status 0xc0000139
FAIL    testwsStream    0.299s
FAIL
PS C:\Users\kamal\Desktop\testwsStream> go1.20.exe mod tidy
PS C:\Users\kamal\Desktop\testwsStream> go1.20.exe test ./... -v -race
=== RUN   TestFoo
0
==================
WARNING: DATA RACE
Write at 0x00c000121968 by goroutine 8:
  testwsStream.makeRace.func1()
      C:/Users/kamal/Desktop/testwsStream/main_test.go:12 +0x39

Previous read at 0x00c000121968 by goroutine 7:
  testwsStream.makeRace()
      C:/Users/kamal/Desktop/testwsStream/main_test.go:15 +0x114
  testwsStream.TestFoo()
      C:/Users/kamal/Desktop/testwsStream/main_test.go:20 +0x24
  testing.tRunner()
      C:/Users/kamal/sdk/go1.20/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      C:/Users/kamal/sdk/go1.20/src/testing/testing.go:1629 +0x47

Goroutine 8 (running) created at:
  testwsStream.makeRace()
      C:/Users/kamal/Desktop/testwsStream/main_test.go:11 +0x104
  testwsStream.TestFoo()
      C:/Users/kamal/Desktop/testwsStream/main_test.go:20 +0x24
  testing.tRunner()
      C:/Users/kamal/sdk/go1.20/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      C:/Users/kamal/sdk/go1.20/src/testing/testing.go:1629 +0x47

Goroutine 7 (running) created at:
  testing.(*T).Run()
      C:/Users/kamal/sdk/go1.20/src/testing/testing.go:1629 +0x805
  testing.runTests.func1()
      C:/Users/kamal/sdk/go1.20/src/testing/testing.go:2036 +0x8d
  testing.tRunner()
      C:/Users/kamal/sdk/go1.20/src/testing/testing.go:1576 +0x216
  testing.runTests()
      C:/Users/kamal/sdk/go1.20/src/testing/testing.go:2034 +0x87c
  testing.(*M).Run()
      C:/Users/kamal/sdk/go1.20/src/testing/testing.go:1906 +0xb44
  main.main()
      _testmain.go:47 +0x2e9
==================
    testing.go:1446: race detected during execution of test
--- FAIL: TestFoo (0.00s)
=== NAME
    testing.go:1446: race detected during execution of test
FAIL
FAIL    testwsStream    0.323s
FAIL

@kamalshkeir
Copy link
Author

@randall77 after update gcc to 13.2.0 it worked with go1.22

PS C:\Users\kamal\Desktop\testwsStream> gcc --version
gcc.exe (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders, r7) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

PS C:\Users\kamal\Desktop\testwsStream> go test ./... -v -race
=== RUN   TestFoo
0
==================
WARNING: DATA RACE
Write at 0x00c00000aea8 by goroutine 8:
  testwsStream.makeRace.func1()
      C:/Users/kamal/Desktop/testwsStream/main_test.go:12 +0x33

Previous read at 0x00c00000aea8 by goroutine 7:
  testwsStream.makeRace()
      C:/Users/kamal/Desktop/testwsStream/main_test.go:15 +0x10c
  testwsStream.TestFoo()
      C:/Users/kamal/Desktop/testwsStream/main_test.go:20 +0x1c
  testing.tRunner()
      C:/Program Files/Go/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      C:/Program Files/Go/src/testing/testing.go:1742 +0x44

Goroutine 8 (running) created at:
  testwsStream.makeRace()
      C:/Users/kamal/Desktop/testwsStream/main_test.go:11 +0xfc
  testwsStream.TestFoo()
      C:/Users/kamal/Desktop/testwsStream/main_test.go:20 +0x1c
  testing.tRunner()
      C:/Program Files/Go/src/testing/testing.go:1689 +0x21e
  testing.(*T).Run.gowrap1()
      C:/Program Files/Go/src/testing/testing.go:1742 +0x44

Goroutine 7 (running) created at:
  testing.(*T).Run()
      C:/Program Files/Go/src/testing/testing.go:1742 +0x825
  testing.runTests.func1()
      C:/Program Files/Go/src/testing/testing.go:2161 +0x85
  testing.tRunner()
      C:/Program Files/Go/src/testing/testing.go:1689 +0x21e
  testing.runTests()
      C:/Program Files/Go/src/testing/testing.go:2159 +0x8be
  testing.(*M).Run()
      C:/Program Files/Go/src/testing/testing.go:2027 +0xf17
  main.main()
      _testmain.go:47 +0x2bd
==================
    testing.go:1398: race detected during execution of test
--- FAIL: TestFoo (0.00s)
FAIL
FAIL    testwsStream    0.275s
FAIL

@randall77
Copy link
Contributor

Ok, we're officially way past my windows knowledge. Maybe a windows expert would know what this issue might be.
It may just be that we don't support mingw 8 any more, which would mean we just need to fix #61916. (But your test for that requirement looked ok, so maybe it is a different mingw 8 compatibility problem than mentioned in the race detector requirements.)
@golang/windows

@seankhliao seankhliao added OS-Windows NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Apr 20, 2024
@seankhliao seankhliao changed the title race tag: since go1.22 , running a program or running test with tag -race exit the program with status 0xc0000139 without any message for -v tag x/website: unclear C compiler requirements for race detector on windows Apr 20, 2024
@gopherbot gopherbot added this to the Unreleased milestone Apr 20, 2024
@alexbrainman
Copy link
Member

this is likely a C toolchain issue.

I also agree. -race flag uses C toolchain to build your code. So if your C toolchain does not work with go1.22 you will have a problem.

It may just be that we don't support mingw 8 any more, which would mean we just need to fix #61916.

Yes. #61916 looks similar. Unfortunately I do not know much about C compilers. Maybe others will help. Perhaps @thanm has some suggestions - he was fixing similar errors at some stage.

If gcc 13.2.0 works for you, just use it.

Alex

@qmuntal
Copy link
Contributor

qmuntal commented Apr 22, 2024

Investigated this a bit. Looks like WakeByAddressSingle couldn't be loaded from kernel32.dll, in which case it is the same issue as #61058. See more details in #61058 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. website
Projects
None yet
Development

No branches or pull requests

6 participants