Description
Issue Description
In the following code:
https://github.com/dotnet/msbuild/blob/main/src/Utilities/ToolTask.cs
The private field _terminatedTool
has not be initialized in method ExecuteTool()
. As a result, in rare cases where:
ToolTask.Execute()
being called multiple times from derived classes, and;- The tool execution being timed out once.
Such timed-out state will be incorrectly permanent, impacting all following ToolTask.Execute()
calls, and forcing the method to return false
even if the execution succeeded.
The problem can be easily addressed by reinitializing _terminatedTool
field to false
in method ExecuteTool()
, along with other private fields.
Thanks!
Steps to Reproduce
- Create a CLI tool that would wait the amount of time (ms) specified on command line;
- Create a
ToolTask
derived class to execute that tool; - Override
Execute()
, callingbase.Execute()
multiple times to execute the tool multiple times; - In the first execution, set delay to a larger value (>100s), and set it to smaller value in all subsequent execution (< 1s);
- Set
Timeout
of the task to 5s, so the first call will timed out, and subsequent ones won't; - Watch how all subsequent
base.Execute()
returnsfalse
, so the task never succeeds.
Expected Behavior
The first execution timed out (and fail), but subsequent execution should succeed.
Actual Behavior
After the first execution timed out, all subsequent execution failed even if they actually succeeded.
Analysis
Private field _terminatedTool
has not been reinitialized correctly in ToolTask.ExecuteTool()
method.
Versions & Configurations
The latest version (17.5).