-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
A crash in evaluator causes MSBuild to fail the build with 0 errors 0 warnings #6460
Comments
The exception occurred as part of this scenario: |
|
Hmm, I happened to have a file with this name in that location: Directory: This causes the ArgumentException in Path.Combine. |
No, the debugger was lying to me, the |
OK, I have a minimal repro: Paste this into 1.csproj:
In the same directory, create a file with the name |
Hmm, but this small repro does print the full exception call stack:
|
Maybe there won't be an exception if this happens in a worker node?? |
Basically having files with |
HAH!!!! I got it! RequestBuilder catch block has a hole here for non-fatal exceptions:
Modify the previous repro to use this project instead:
|
Output:
|
Well, that was Sunday well spent, even if I say so myself. |
So we could add a very specific exception for if it finds an invalid path character, but I highly doubt that's the only way "build failed 0 warnings 0 errors" could come about in Evaluator. Finding all the possible sources of error would be a huge task. A relatively easy fix that would at least get the user a stack to try to identify what went wrong is if we wrapped all of Evaluate in a try/catch and logged a fairly generic error with a stack immediately rather than letting it bubble up to BuildAndReport, which clearly has no idea what to do. Does that sound good enough? |
I recommend you turn on first-chance exceptions in the debugger and step through building this project: You will see that the first catch block is here:
The second catch block is here:
The problem is that this second catch block is effectively throwing away all non-critical exceptions. I don't care about this specific exception (invalid char). This is just a convenient representative of a class of exceptions in the build that will go unnoticed when they happen. As you correctly point out, there could be a plethora of these. We need to harden against all potential exceptions that bubble up to here - if an exception bubbles up to here, it's a bug in the engine. I think that this catch block needs to do three things:
try/catch around the Evaluator is probably not the right thing because if there's an exception like this one, we probably don't want to continue the build. In addition to all that hardening, we need to fix this particular case at the source - this needs to happen here:
We should sanitize inputs before we call But it is vastly more important to harden the engine and safeguard against any non-critical exceptions, not just this one. |
I also meant to add that this line is too complicated and we need to extract several subexpressions:
|
I was thinking of the try/catch throwing the exception after making it nicer, since then we could actually say it's an error in Evaluate rather than that there's some bug with MSBuild, and we aren't entirely sure. On the other hand, the second catch will still swallow it, as you said, so maybe that's best. We could also split the difference and throw an internal exception in RequestBuilder with a message from the thrown exception (i.e., "Error in Evaluate") if present. |
I’d rather have the raw original exception with full stack, don’t see much value in wrapping it. I would add a text before or after it saying: there was an exception in MSBuild, please file an issue. I believe we already do it elsewhere, need to find it. |
Not sure how this is related, but this annoying file |
We should harden MSBuild against crashes in various places to ensure that we get a decent behavior and report the original stack.
A sample exception I'm seeing here causes these symptoms:
In the Path.Combine, the first argument is:
C:\A\src\Shims
and the second one is:
\Users\kirill\AppData\Local\Microsoft\A\Temp\WebTooling\Schemas\JSON\Catalog\https
Throwing this ArgumentException from this location causes the problem:
msbuild/src/Build/Evaluation/LazyItemEvaluator.cs
Line 431 in d07c47a
The text was updated successfully, but these errors were encountered: