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

Avoid bug during FUTDC validation after solution build completes #9161

Merged
merged 1 commit into from
Jul 13, 2023

Conversation

drewnoakes
Copy link
Member

@drewnoakes drewnoakes commented Jul 13, 2023

Fixes #9152

In some cases (such as when FUTDC logging is enabled) we run a validation pass to report to the user when their projects appear out of date despite just having been built. This feature alerts users to overbuild and provides useful diagnostic information to correct it.

#9130 fixed a bug related to F5 builds. It introduced a race condition that can lead to the error reported in #9152.

Our CurrentSolutionBuildContext value is set when the SBM starts the solution build, and cleared to null when it completes.

Our validation logic runs async, and can complete after the SBM completes. In such cases, it can observe a null CurrentSolutionBuildContext value, which is not supported by the current code.

This change captures the CurrentSolutionBuildContext value early on to ensure it's non-null when we need it later on, and passes the specific value down, preventing any issues from null values.

(This PR targets 17.8. I will back-port it to 17.7 too.)

Microsoft Reviewers: Open in CodeFlow

In some cases (such as when FUTDC logging is enabled) we run a validation pass to report to the user when their projects appear out of date despite just having been built. This feature alerts users to overbuild and provides useful diagnostic information to correct it.

dotnet#9130 fixed a bug related to F5 builds. It introduced a race condition that can lead to the error reported in dotnet#9152.

Our `CurrentSolutionBuildContext` value is set when the SBM starts the solution build, and cleared to `null` when it completes.

Our validation logic runs async, and can complete after the SBM completes. In such cases, it can observe a null `CurrentSolutionBuildContext` value, which is not supported by the current code.

This change captures the `CurrentSolutionBuildContext` value early on to ensure it's non-null when we need it later on, and passes the specific value down, preventing any issues from null values.
@drewnoakes drewnoakes added Bug Regression Regressions from a previous (typically public) build or release. Feature-Up-to-date Build up-to-date check that avoids shelling out to MSBuild unless necessary. labels Jul 13, 2023
@drewnoakes drewnoakes added this to the 17.8 milestone Jul 13, 2023
@drewnoakes drewnoakes requested a review from a team as a code owner July 13, 2023 01:05
@drewnoakes drewnoakes merged commit 6c8ef14 into dotnet:main Jul 13, 2023
@drewnoakes drewnoakes deleted the fix-9152-futdc-exception branch July 13, 2023 19:48
{
_solutionBuildEventListener.NotifySolutionBuildStarting();
Assumes.NotNull(_solutionBuildContextProvider.CurrentSolutionBuildContext);
solutionBuildContext = _solutionBuildContextProvider.CurrentSolutionBuildContext;
Copy link
Member

Choose a reason for hiding this comment

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

Can we be confident at this point that the CurrentSolutionBuildContext is not cleared? Or do we need to have a null check here as well?

Copy link
Member

Choose a reason for hiding this comment

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

Never mind..null check is below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry I missed your comment when merging from my phone.

Yes the check is below, which is earlier in time. The methods are written backwards here. One days we'll refactor this system to be easier to follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature-Up-to-date Build up-to-date check that avoids shelling out to MSBuild unless necessary. Regression Regressions from a previous (typically public) build or release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exception in FUTDC
3 participants