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

Enable Windows runs of AddressSanitizer #95758

Merged
merged 11 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions eng/pipelines/runtime-sanitized.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extends:
platforms:
- linux_x64
- osx_x64
- windows_x64
variables:
- name: _nativeSanitizersArg
value: -fsanitize address
Expand Down Expand Up @@ -81,6 +82,38 @@ extends:
scenarios:
- normal

#
# Build the whole product with CoreCLR and run libraries tests with AddressSanitizer
#
- template: /eng/pipelines/common/platform-matrix.yml
parameters:
jobTemplate: /eng/pipelines/common/global-build-job.yml
buildConfig: Debug
Copy link
Member

Choose a reason for hiding this comment

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

Does Debug make a difference? That is, is asan supported in Release? Is it better/worse?

Copy link
Member Author

Choose a reason for hiding this comment

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

ASAN is supported in release, but it can miss some checks as the instrumentation pass runs after many optimization passes, which can cause false negatives on some of the stack usage validation.

runtimeFlavor: coreclr
platforms:
- windows_x64
variables:
- name: _nativeSanitizersArg
value: -fsanitize address
jobParameters:
testGroup: innerloop
nameSuffix: CoreCLR_LibrariesTests
buildArgs: -s clr+libs+libs.tests -c $(_BuildConfig) -rc Checked $(_nativeSanitizersArg) /p:ArchiveTests=true
timeoutInMinutes: 360
# Hard-code queues here as we don't want to run on pre Win-10 queues
# and we don't want to overcompilcate helix-queues-setup.yml just for this case.
helixQueues:
- Windows.Amd64.Server2022.Open
- Windows.11.Amd64.Client.Open
# extra steps, run tests
postBuildSteps:
- template: /eng/pipelines/libraries/helix.yml
parameters:
creator: dotnet-bot
testRunNamePrefixSuffix: Libraries_$(_BuildConfig)
scenarios:
- normal

#
# NativeAOT release build and smoke tests with AddressSanitizer
#
Expand All @@ -92,6 +125,7 @@ extends:
platforms:
- linux_x64
- osx_x64
- windows_x64
variables:
- name: _nativeSanitizersArg
value: -fsanitize address
Expand Down
4 changes: 4 additions & 0 deletions eng/testing/linker/project.csproj.template
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,8 @@

<Import Project="{NativeSanitizersTargets}" />

<ItemGroup>
<Content Include="@(SanitizerRuntimeToCopy->'{SanitizerRuntimeFolder}/%(Identity)')" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
3 changes: 2 additions & 1 deletion eng/testing/linker/trimmingTests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
.Replace('{MicrosoftNetCoreAppRuntimePackDir}', '$(MicrosoftNetCoreAppRuntimePackDir)')
.Replace('{NativeSanitizersTargets}', '$(RepositoryEngineeringDir)nativeSanitizers.targets')
.Replace('{AppHostSourcePath}', '$(AppHostSourcePath)')
.Replace('{SingleFileHostSourcePath}', '$(SingleFileHostSourcePath)'))"
.Replace('{SingleFileHostSourcePath}', '$(SingleFileHostSourcePath)')
.Replace('{SanitizerRuntimeFolder}', '$(DotNetHostBinDir)'))"
Overwrite="true" />
<Copy SourceFiles="$(_projectSourceFile);
@(_additionalProjectSourceFiles)"
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/pgosupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function(add_pgo TargetName)
endif()
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
endif(CLR_CMAKE_HOST_WIN32)
elseif(CLR_CMAKE_PGO_OPTIMIZE)
elseif(CLR_CMAKE_PGO_OPTIMIZE AND NOT CLR_CMAKE_ENABLE_SANITIZERS)
if(CLR_CMAKE_HOST_WIN32)
set(ProfileFileName "${TargetName}.pgd")
else(CLR_CMAKE_HOST_WIN32)
Expand Down
4 changes: 3 additions & 1 deletion src/tests/readytorun/tests/mainv1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<CrossGenTest>false</CrossGenTest>
<!-- https://github.com/dotnet/runtime/issues/73138 -->
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
<!-- This test launches crossgen2 with dotnet, so we would need a non-sanitzed jitinterface library. To simplify our infrastructure, we'll instead skip this test. -->
<CLRTestTargetUnsupported Condition="'$(EnableNativeSanitizers)' != ''">true</CLRTestTargetUnsupported>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="fieldgetter.ilproj" />
Expand Down Expand Up @@ -156,7 +158,7 @@ export DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun
]]></CLRTestBashPreCommands>
</PropertyGroup>

<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build">
<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build" Condition="'$(CLRTestTargetUnsupported)' != 'true'">
<PropertyGroup>
<TestAssemblyName>test.dll</TestAssemblyName>
<TestAssemblySourcePath>$(OutputPath)/../testv1/test/</TestAssemblySourcePath>
Expand Down
4 changes: 3 additions & 1 deletion src/tests/readytorun/tests/mainv2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<CrossGenTest>false</CrossGenTest>
<!-- https://github.com/dotnet/runtime/issues/73954 -->
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
<!-- This test launches crossgen2 with dotnet, so we would need a non-sanitzed jitinterface library. To simplify our infrastructure, we'll instead skip this test. -->
<CLRTestTargetUnsupported Condition="'$(EnableNativeSanitizers)' != ''">true</CLRTestTargetUnsupported>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="fieldgetter.ilproj" />
Expand Down Expand Up @@ -158,7 +160,7 @@ export DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun
]]></CLRTestBashPreCommands>
</PropertyGroup>

<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build">
<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build" Condition="'$(CLRTestTargetUnsupported)' != 'true'">
<PropertyGroup>
<TestAssemblyName>test.dll</TestAssemblyName>
<TestV1AssemblySourcePath>$(OutputPath)/../testv1/test/</TestV1AssemblySourcePath>
Expand Down
Loading