Add random number to multishell symlinks#1536
Open
joliss wants to merge 1 commit intoSchniz:masterfrom
Open
Conversation
This protects against collisions when multiple shells are started in parallel inside Bubblewrap sandboxes, as each shell will have the same timestamp and the same low PID (e.g. 2), since Bubblewrap sandboxes have isolated PID spaces.
|
|
@joliss is attempting to deploy a commit to the Gal Schlezinger's projects Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This protects against collisions when multiple shells are started in parallel inside Bubblewrap sandboxes, as each shell will have the same timestamp and the same low PID (e.g. 2), since Bubblewrap sandboxes have isolated PID spaces.
We're already using
fastrandas a transitive dependency throughtempfile.This is the only place where fnm relies on
std::process::id()for deconflicting.How I actually ran into this
I'm loading
fnmin my.bashrceven in non-interactive shells (i.e. before[ -z "$PS1" ] && return), so that Codex has access to fnm'snodebinary:With this, Codex in VS Code (via a VS Code remote into Linux) was hitting intermittent errors like
Can't create the symlink for multishells at "/tmp/fnm_multishells/...". File exists.Codex analysis
Yes. The trigger is the `fnm` init at `.bashrc`:What I found:
/tmpoverride is necessary in this sandbox. Without it,fnm env --shell=bashtries/run/user/1000/fnm_multishellsand fails because that path is read-only here.File existsis a separate issue. The tool’s default wrapper launches/bin/bash -c ..., and bash is auto-reading~/.bashrcin this environment even for non-interactive commands. That makes thefnmline run on basically every command.fnmappears to create multishell links named like/tmp/fnm_multishells/<pid>_<timestamp_ms>. In these sandboxes, thefnmprocess keeps getting the same tiny PID (3) because each command starts in a fresh PID namespace, while/tmpis shared across sandboxes.I was able to reproduce the collision directly: I launched 6 parallel
XDG_RUNTIME_DIR=/tmp fnm env --shell=bashcalls under/bin/sh. Five succeeded with paths like3_1774452861101through3_1774452861106, and one failed with:So the root cause is:
fnmmust be redirected away from/run/user/1000in this sandbox..bashrcduring tool commands.fnm’s multishell naming collides across fresh PID namespaces sharing the same/tmp.Your
set -x; source .bashrcidea helped confirm that sourcing.bashrcitself is fine in isolation; the collision only shows up when multiple sandboxed command invocations hitfnmat nearly the same time.