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/playground: non-deterministic return of process ID #45306

Closed
trafalmuffti opened this issue Mar 30, 2021 · 3 comments
Closed

x/playground: non-deterministic return of process ID #45306

trafalmuffti opened this issue Mar 30, 2021 · 3 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@trafalmuffti
Copy link

What did you do?

https://play.golang.org/p/PJWAz9xPONU

What did you expect to see?

A consistent process ID.

What did you see instead?

There is a small chance that I recieve a different process ID.
This is potentially because the process ID is assigned to a concurrent user.

I guess the sandboxed environment doesn't emulate syscall returns or create a new PID namespace per playground execution.

@gopherbot gopherbot added this to the Unreleased milestone Mar 30, 2021
@prattmic
Copy link
Member

@toothrot correct me if I'm wrong, but I believe that the playground sandbox looks like a program from x/playground as init (PID 1), which then launches the actual user binary as a child process.

Since the init process is a Go process, it will not necessary create a consistent number of threads. Each thread takes a PID, so if the number of threads in the parent varies, then the PID of the child will vary.

FWIW, I don't think os.Getpid is something we should guarantee remains consistent across runs. That said, I was under the impression that we cached output to keep it more consistent (plus reduce load). Yet, running https://play.golang.org/p/z12AQN-w-hD several times does yield different results, so perhaps our caching is much less aggressive than I thought?

@prattmic prattmic added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 30, 2021
@toothrot
Copy link
Contributor

@prattmic You're correct, here's the actual Dockerfile for the sandbox: https://github.com/golang/playground/blob/master/sandbox/Dockerfile.gvisor, which is started from here: https://github.com/golang/playground/blob/master/sandbox/sandbox.go#L448. --init is not specified, meaning we are indeed PID 1.

The memcached server crashed again. I restarted it, and the responses should be cached.

That being said, I don't think this is an issue otherwise.

@trafalmuffti
Copy link
Author

Now that it is statistically impossible for a program to have non-deterministic output in the Go playground, it would be unreasonable of me to think this is still an issue.

But it is aesthetically contradictory to have faketime but no fakepid.

@golang golang locked and limited conversation to collaborators Mar 30, 2022
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.
Projects
None yet
Development

No branches or pull requests

4 participants