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

misc/cgo/testcshared: test failure on Google Pixelbook #26730

Closed
danicat opened this issue Aug 1, 2018 · 3 comments
Closed

misc/cgo/testcshared: test failure on Google Pixelbook #26730

danicat opened this issue Aug 1, 2018 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Testing An issue that has been verified to require only test changes, not just a test failure.
Milestone

Comments

@danicat
Copy link
Contributor

danicat commented Aug 1, 2018

What version of Go are you using (go version)?

go version go1.10.3 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/danielapetruzalek/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/danielapetruzalek/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build074359831=/tmp/go-build -gno-record-gcc-switches"

What did you do?

cd go/src
./all.bash

What did you expect to see?

ALL TESTS PASSED

What did you see instead?

##### ../misc/cgo/testcshared
--- FAIL: TestUnexportedSymbols (0.64s)
    cshared_test.go:353: run: [go build -buildmode=c-shared -installsuffix testcshared -o libgo2.so libgo2]
    cshared_test.go:367: run: [gcc -fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build783986620=/tmp/go-build -gno-record-gcc-switches -I pkg/linux_amd64_shared -o testp2 main2.c -Wl,--no-as-needed libgo2.so]
    cshared_test.go:373: run: [./testp2]
    cshared_test.go:376: # NAN ChangeLog
**
FAIL
2018/07/31 23:09:06 Failed: exit status 1

I've tried two other times and the message on the last line (after "cshared_test.go:376") changed all times, suggesting some random values were being read from fd 30. I've tracked this change to the issue #23784 and CL 108537 (https://golang.org/cl/108537).

I've recompiled the binaries to use fd 100 like it was originally and I got the tests to pass.

I'm testing Go on the new Google Pixelbook and it seems that fd 30 is being used already. I wonder if instead of choosing an arbitrary number we could have a more safe way to select the fd? Or use another technique to run this test?

@ianlancetaylor ianlancetaylor changed the title build: misc/cgo/testcshared failure on Google Pixelbook misc/cgo/testcshared: test failure on Google Pixelbook Aug 1, 2018
@ianlancetaylor ianlancetaylor added Testing An issue that has been verified to require only test changes, not just a test failure. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 1, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.12 milestone Aug 1, 2018
@ianlancetaylor
Copy link
Contributor

Any idea why descriptor 30 is open?

Perhaps we should just close the descriptor first, somehow.

I'm certainly to using another technique if you have any suggestions.

@danicat
Copy link
Contributor Author

danicat commented Aug 1, 2018

I think I've found something:

$ ls -la /proc/$$/fd
total 0
dr-x------. 2 danielapetruzalek danielapetruzalek  0 Aug  1 01:24 .
dr-xr-xr-x. 9 danielapetruzalek danielapetruzalek  0 Jul 31 22:05 ..
lrwx------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:24 0 -> /dev/pts/0
lrwx------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:24 1 -> /dev/pts/0
lrwx------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:24 2 -> /dev/pts/0
lrwx------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:24 255 -> /dev/pts/0
lr-x------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:24 30 -> /usr/share/code/resources/app/node_modules.asar
lrwx------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:24 35 -> socket:[43689]
lr-x------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:24 36 -> /usr/share/code/resources/app/node_modules.asar
lr-x------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:24 37 -> /usr/share/code/resources/electron.asar
lr-x------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:24 44 -> /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf
(...)

It seems that fd 30 is being used by VS Code. I was using the built in terminal in vscode to build the project.

I've ran it in the standalone terminal and it's working as expected -> no use of fd 30:

$ ls -la /proc/$$/fd
total 0
dr-x------. 2 danielapetruzalek danielapetruzalek  0 Aug  1 01:25 .
dr-xr-xr-x. 9 danielapetruzalek danielapetruzalek  0 Aug  1 01:25 ..
lrwx------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:25 0 -> /dev/pts/1
lrwx------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:25 1 -> /dev/pts/1
lr-x------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:25 19 -> anon_inode:inotify
lrwx------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:25 2 -> /dev/pts/1
lr-x------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:25 20 -> pipe:[2849]
l-wx------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:25 21 -> pipe:[2849]
lrwx------. 1 danielapetruzalek danielapetruzalek 64 Aug  1 01:25 255 -> /dev/pts/1

And the build passes:

(...)
##### API check

ALL TESTS PASSED
---
Installed Go for linux/amd64 in /home/danielapetruzalek/golang/go
Installed commands in /home/danielapetruzalek/golang/go/bin
*** You need to add /home/danielapetruzalek/golang/go/bin to your PATH.

That means that this potentially affects anyone using the terminal embedded into VS code. Which leaves the question on how we detect if the fd 30 is being used by another process in runtime. I'm not an expert in OS's, but I'll try to study more about this issue.

@gopherbot
Copy link

Change https://golang.org/cl/127395 mentions this issue: misc/cgo/testcshared: force descriptor 30 to be closed when execing test

@golang golang locked and limited conversation to collaborators Aug 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Testing An issue that has been verified to require only test changes, not just a test failure.
Projects
None yet
Development

No branches or pull requests

3 participants