Don't crash reading the config of a subrepo with no remote tree - #3577
Merged
peterebden merged 1 commit intoAug 18, 2026
Merged
Conversation
peterebden
reviewed
Aug 17, 2026
| tree = &pb.Tree{} | ||
| } | ||
| if tree.Root == nil { | ||
| tree = &pb.Tree{Root: &pb.Directory{}, Children: tree.Children} |
Collaborator
There was a problem hiding this comment.
Suggested change
| tree = &pb.Tree{Root: &pb.Directory{}, Children: tree.Children} | |
| tree.Root = &pb.Directory{} |
Think this is slightly clearer about what it wants to do
SubrepoFS looks a subrepo's output tree up by label and passes whatever it
finds to remotefs.New:
tree := c.subrepoTrees[target.Label]
return remotefs.New(c.remoteFSClient, tree, root)
subrepoTrees is populated only when a target's outputs are set from a remote
build, so a subrepo built locally, served from cache, or not yet built has
no entry and tree is nil. New then dereferences it while indexing the tree's
children, segfaulting at addr=0x18 during readSubrepoConfig, which calls
Subrepo.FS() unconditionally to look for .plzconfig.
A nil tree (or one without a root) now yields an empty filesystem, so the
lookup reports that the file does not exist and parsing carries on, which is
already how a subrepo without a .plzconfig is handled.
jackmarsh
force-pushed
the
fix/remotefs-nil-tree
branch
from
August 17, 2026 13:06
110fa9d to
df325f8
Compare
Contributor
Author
|
Applied, thanks - reads better. |
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.
Building a Rust plugin against a repo with ~100 crate subrepos, we hit an intermittent segfault under remote execution whenever Please read a subrepo's config:
Note the literal
0x0argument.SubrepoFSlooks the subrepo's output tree up by label and passes whatever it finds straight toremotefs.New:subrepoTreesis only ever populated in one place (utils.go, when a target's outputs are set from a remote build), so a subrepo that was built locally, served from the cache, or not built yet has no entry, andtreeis nil.Newthen doesappend(tree.Children, tree.Root)and dies.readSubrepoConfigcallsSubrepo.FS()unconditionally — it has to, in order to look for.plzconfig— so any repo whose subrepo targets can come from cache rather than a fresh remote build can hit this.That matches what we saw: it was sensitive to cache state and flipped between otherwise identical runs.
This makes a nil tree (or one with no root) produce an empty filesystem, so the config lookup reports "does not exist" and parsing continues — which is already the handling for a subrepo that has no
.plzconfig. The added test panics at the sameaddr=0x18without the change and passes with it.plz test //src/remote/...is green.