You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a task runs in a TaskHost, file accesses reported through EngineServices.ReportFileAccess are collected and replayed unconditionally, ignoring BuildParameters.ReportFileAccesses. The equivalent in-proc code path does honor the flag. The same task therefore behaves differently depending only on where it happens to be scheduled.
This was found while investigating #14824, and it is the reason that defect crashed builds which had never asked for file-access reporting.
Details
The in-proc engine gates on the build parameter (src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs):
TaskHostConfiguration carries no equivalent of ReportFileAccesses, so the TaskHost has no way to know the flag is off.
Impact
Inconsistent behavior. A task that calls ReportFileAccess is a no-op in-proc when reporting is disabled, but is collected, serialized across the pipe and replayed into the FileAccessManager when the same task runs in a TaskHost — which now happens by default for every task not annotated with MSBuildMultiThreadableTaskAttribute under -mt.
Wasted work. Every TaskHost task completion pays for serializing a List<FileAccessData> even when nothing will consume it.
It turned TaskHost file-access data is corrupted under multithreaded MSBuild #14824 from "corrupted data for opted-in users" into "builds crash with MSB4018 / MSB1025 even without -reportfileaccesses". I reproduced that crash with MSBuild.exe repro.proj using nothing but a TaskHostFactoryUsingTask — no -mt, no -reportfileaccesses.
Expected behavior
ReportFileAccess should be a no-op end to end when BuildParameters.ReportFileAccesses is false, regardless of where the task executes.
Suggested fix
Plumb the flag into TaskHostConfiguration so OutOfProcTaskHostNode.EngineServicesImpl.ReportFileAccess can skip collection entirely, and gate the replay in TaskHostTask.HandleTaskHostTaskComplete on _buildComponentHost.BuildParameters.ReportFileAccesses for older/mismatched task hosts.
Note that gating alone would only have hidden #14824; the deserialization fix there is still required.
Summary
When a task runs in a TaskHost, file accesses reported through
EngineServices.ReportFileAccessare collected and replayed unconditionally, ignoringBuildParameters.ReportFileAccesses. The equivalent in-proc code path does honor the flag. The same task therefore behaves differently depending only on where it happens to be scheduled.This was found while investigating #14824, and it is the reason that defect crashed builds which had never asked for file-access reporting.
Details
The in-proc engine gates on the build parameter (
src/Build/BackEnd/Components/RequestBuilder/TaskHost.cs):The TaskHost process does not (
src/MSBuild/OutOfProcTaskHostNode.cs):Neither does the replay in the owning worker node (
src/Build/Instance/TaskFactories/TaskHostTask.cs):TaskHostConfigurationcarries no equivalent ofReportFileAccesses, so the TaskHost has no way to know the flag is off.Impact
ReportFileAccessis a no-op in-proc when reporting is disabled, but is collected, serialized across the pipe and replayed into theFileAccessManagerwhen the same task runs in a TaskHost — which now happens by default for every task not annotated withMSBuildMultiThreadableTaskAttributeunder-mt.List<FileAccessData>even when nothing will consume it.MSB4018/MSB1025even without-reportfileaccesses". I reproduced that crash withMSBuild.exe repro.projusing nothing but aTaskHostFactoryUsingTask— no-mt, no-reportfileaccesses.Expected behavior
ReportFileAccessshould be a no-op end to end whenBuildParameters.ReportFileAccessesisfalse, regardless of where the task executes.Suggested fix
Plumb the flag into
TaskHostConfigurationsoOutOfProcTaskHostNode.EngineServicesImpl.ReportFileAccesscan skip collection entirely, and gate the replay inTaskHostTask.HandleTaskHostTaskCompleteon_buildComponentHost.BuildParameters.ReportFileAccessesfor older/mismatched task hosts.Note that gating alone would only have hidden #14824; the deserialization fix there is still required.