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

build: plan9-amd64-9front builder is unhappy #19388

Closed
bradfitz opened this issue Mar 3, 2017 · 13 comments
Closed

build: plan9-amd64-9front builder is unhappy #19388

bradfitz opened this issue Mar 3, 2017 · 13 comments
Labels
Builders x/build issues (builders, bots, dashboards) FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Plan9
Milestone

Comments

@bradfitz
Copy link
Contributor

bradfitz commented Mar 3, 2017

@0intro, let's fix the plan9-amd64-9front builder or kill it.

Its column of red is distracting.

@bradfitz bradfitz added Builders x/build issues (builders, bots, dashboards) NeedsFix The path to resolution is known, but the work has not been done. OS-Plan9 labels Mar 3, 2017
@bradfitz bradfitz added this to the Go1.9 milestone Mar 3, 2017
@bradfitz
Copy link
Contributor Author

David, any update here?

@bradfitz bradfitz modified the milestones: Gccgo, Go1.9, Go1.10 Jun 15, 2017
@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 5, 2017

David, please stop this builder. It is still red.

Unless there is a plan to work on it and make it not red. But I don't believe there is such a plan, so it's not doing any good keeping it.

@0intro
Copy link
Member

0intro commented Aug 6, 2017

The plan9-amd64-9front builder is currently failing because one of the runtime/trace test is running out of memory (see build log).

I've haven't fixed it yet because I spent my time on other issues, but I see no reason why this issue couldn't be fixed as well.

So, my plan would be investigate and fix this issue.

I'd prefer to keep the plan9-amd64-9front builder for now. I'm ready to convert it to the buildlet if you provide me the key.

Thanks.

@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 6, 2017

Okay, I sent you a host key.

@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 6, 2017

9front builder is now failing with:

##### Building Go bootstrap tool.
cmd/dist
ERROR: Cannot find /tmp/workdir-host-plan9-amd64-0intro/go1.4/bin/go.
Set $GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4.

If you update your buildlet to get golang/build@a7e875c then you can set your own GOROOT_BOOTSTRAP without me having to configure it.

@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 6, 2017

(and then let me know and I'll clear the failed builds from the dashboard)

@0intro
Copy link
Member

0intro commented Aug 6, 2017

This is what I did, but it didn't work.

I've looked a bit and this is what happened:

  • I set GOROOT_BOOTSTRAP=/usr/go-plan9-arm-bootstrap
  • I started the buildlet
  • The buildlet set GOROOT_BOOTSTRAP=/tmp/workdir-host-plan9-arm-0intro/go1.4 (in initGorootBootstrap)
  • I stopped the buildlet before it did any build
  • Consequently, GOROOT_BOOTSTRAP is now set to /tmp/workdir-host-plan9-arm-0intro/go1.4
  • I started the buildlet and it ran a build with GOROOT_BOOTSTRAP=/tmp/workdir-host-plan9-arm-0intro/go1.4, which didn't work

On Plan 9, the environment is shared with the parent process. Since the GOROOT_BOOTSTRAP is properly set only in handleExec, the buildlet will override GOROOT_BOOTSTRAP with the default value if handleExec hasn't been called.

I think we should not set GOROOT_BOOTSTRAP to its default value if GOROOT_BOOTSTRAP has already been set and contains an existing directory. I've submitted CL 53475.

@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 6, 2017

I think we should not set GOROOT_BOOTSTRAP to its default value if GOROOT_BOOTSTRAP has already been set and contains an existing directory. I've submitted CL 53475.

I don't like that approach. The whole point of the new-style builders is to have a lot more centralized control over our many builders, rather than have to sysadmin each one separately. I made the conciliatory golang/build@a7e875c change to give builder operators (like you) at least some control of the environment when it's omitted from the central control's config, but if there's a value in dashboard/builders.go, it must override. And if there's nothing specified at all, we need to keep using $WORKDIR/go1.4 as the default, as that's what we've always done before and I don't want to risk breaking any other builders right now. (especially as I'm about to go on leave).

If there's a problem with golang/build@a7e875c then let's understand and fix it. The intent of that change was that we use your system's $GOROOT_BOOTSTRAP if the server's explicit or implicit value doesn't exist. Why didn't my CL work?

@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 6, 2017

On Plan 9, the environment is shared with the parent process.

Oh, that's why!? Plan 9 is different from every other operating system in this regard?

Should Go's os/exec.Cmd.Start() use a rfork flag or something that makes it get its own environment? Go programs are supposed to behave consistently and portably.

Sigh.

I'll consider a workaround.

@0intro
Copy link
Member

0intro commented Aug 6, 2017

This is what happens:

cpu% GOROOT_BOOTSTRAP=/usr/go-plan9-arm-bootstrap
cpu% cat /env/GOROOT_BOOTSTRAP
/usr/go-plan9-arm-bootstrap
cpu% buildlet -coordinator'='farmer.golang.org --reverse-type'='host-plan9-arm-0intro -halt'='false
2017/08/06 20:55:45 buildlet starting.
2017/08/06 20:55:45 Dialing coordinator farmer.golang.org:443 ...
2017/08/06 20:55:46 Doing TLS handshake with coordinator (verifying hostname "farmer.golang.org")...
2017/08/06 20:55:46 Registering reverse mode with coordinator...
2017/08/06 20:55:46 Connected to coordinator; reverse dialing active
cpu% cat /env/GOROOT_BOOTSTRAP
/tmp/workdir-host-plan9-arm-0intro/go1.4
cpu% 

The buildlet overrides the GOROOT_BOOTSTRAP environment variable with the default value (in the initGorootBootstrap function). We lose the initial value of GOROOT_BOOTSTRAP because the environment is shared with the parent on Plan 9.

If I recall correctly, we chose this behavior so the different Go processes could share the same environment, as it it expected between threads on Unix (for example, using clone(_CLONE_VM) on Linux). The drawback is that the environment is also shared with the parent.

For example, the rc shell has the same behavior:

term% foo=foo
term% cat /env/foo
foo
term% rc
term% foo=bar
term% exit
term% cat /env/foo
bar
term% 

@0intro
Copy link
Member

0intro commented Aug 6, 2017

As a simple workaround, on my side, without modifying the buildlet code, is to set GOROOT_BOOTSTRAP=/usr/go-plan9-arm-bootstrap in the loop, just before executing the buildlet.

@bradfitz
Copy link
Contributor Author

bradfitz commented Aug 6, 2017

Perfect. Do that. Or if you prefer, send a change to add GOROOT_BOOTSTRAP=/usr/go-plan9-arm-bootstrap to dashboard/builders.go.

@bradfitz
Copy link
Contributor Author

All three plan9 builders are halfway okay lately.

The arm one is pretty red, but not 100%.

Closing.

@golang golang locked and limited conversation to collaborators Nov 29, 2018
gopherbot pushed a commit that referenced this issue Jun 19, 2020
In os.Getenv and os.Setenv, instead of directly reading and writing the
Plan 9 environment device (which may be shared with other processes),
use a local copy of environment variables cached at the start of
execution. This gives the same semantics for Getenv and Setenv as on
other operating systems which don't share the environment, making it
more likely that Go programs (for example the build tests) will be
portable to Plan 9.

This doesn't preclude writing non-portable Plan 9 Go programs which make
use of the shared environment semantics (for example to have a command
which exports variable definitions to the parent shell). To do this, use
  ioutil.ReadFile("/env/"+key) and
  ioutil.WriteFile("/env/"+key, value, 0666)
in place of os.Getenv(key) and os.Setenv(key, value) respectively.

Note that CL 5599054 previously added env cacheing, citing efficiency
as the reason. However it made the cache write-through, with Setenv
changing the shared environment as well as the cache (so not consistent
with Posix semantics), and Clearenv breaking the sharing of the
environment between the calling thread and other threads (leading to
unpredictable behaviour). Because of these inconsistencies (#8849),
CL 158970045 removed the cacheing again.

This CL restores cacheing but without write-through. The local cache is
initialised at start of execution, manipulated by the standard functions
in syscall/env_unix.go to ensure the same semantics, and exported only
when exec'ing a new program.

Fixes #34971
Fixes #25234
Fixes #19388
Updates #38772

Change-Id: I2dd15516d27414afaf99ea382f0e00be37a570c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/236520
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Fazlul Shahriar <fshahriar@gmail.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
@rsc rsc unassigned 0intro Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Builders x/build issues (builders, bots, dashboards) FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Plan9
Projects
None yet
Development

No branches or pull requests

3 participants