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

Fix potential subinclude lockup #3305

Merged

Conversation

peterebden
Copy link
Collaborator

@peterebden peterebden commented Nov 28, 2024

Think we have an issue in here where isLocal == true and s.pkg == nil; we never activate the target and it never gets built. This happens in the attached test repo when going through //a because of the double-subinclude; it works okay if the subinclude from//c gets there first (because then we are specifically parsing for that target which gets handled elsewhere).

I think this is a reasonably tactical fix; we don't really need the package in this case, it's only used for:

  • :all targets which you can't subinclude anyway
  • Some edge case of Bazel compat which I can't believe anyone is using any more and we should just bin. Anyway I don't think it would end up in this situation since it wouldn't use subinclude()
  • Suggesting target names if they mistype, which is only a nice-to-have UI thing

@peterebden peterebden requested a review from Tatskaari November 28, 2024 15:11
@peterebden peterebden changed the title Test subinclude lockup Fix potential subinclude lockup Nov 29, 2024
@@ -1029,6 +1031,9 @@ func (state *BuildState) ActivateTarget(pkg *Package, label, dependent BuildLabe
if state.ParsePackageOnly && !mode.IsForSubinclude() {
return nil // Some kinds of query don't need a full recursive parse.
} else if label.IsAllTargets() {
if pkg == nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we end up here?

Copy link
Collaborator Author

@peterebden peterebden Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the condition in builtins.go to allow it to continue to activate the target even if the pkg is nil. That happens when we subinclude from inside a subinclude; they don't have a package set when we're executing them.

Copy link
Member

@Tatskaari Tatskaari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense. I wonder why pkg is nil in activate target though. Should it be set based on the context?

@peterebden peterebden merged commit 6ae8e2e into thought-machine:master Dec 3, 2024
13 checks passed
@peterebden peterebden deleted the test-subinclude-lockup branch December 3, 2024 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants