Skip to content

Commit a258bb9

Browse files
authored
Enable Windows runs of AddressSanitizer (#95758)
1 parent 027e2a8 commit a258bb9

File tree

6 files changed

+47
-4
lines changed

6 files changed

+47
-4
lines changed

eng/pipelines/runtime-sanitized.yml

+34
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ extends:
3030
platforms:
3131
- linux_x64
3232
- osx_x64
33+
- windows_x64
3334
variables:
3435
- name: _nativeSanitizersArg
3536
value: -fsanitize address
@@ -81,6 +82,38 @@ extends:
8182
scenarios:
8283
- normal
8384

85+
#
86+
# Build the whole product with CoreCLR and run libraries tests with AddressSanitizer
87+
#
88+
- template: /eng/pipelines/common/platform-matrix.yml
89+
parameters:
90+
jobTemplate: /eng/pipelines/common/global-build-job.yml
91+
buildConfig: Debug
92+
runtimeFlavor: coreclr
93+
platforms:
94+
- windows_x64
95+
variables:
96+
- name: _nativeSanitizersArg
97+
value: -fsanitize address
98+
jobParameters:
99+
testGroup: innerloop
100+
nameSuffix: CoreCLR_LibrariesTests
101+
buildArgs: -s clr+libs+libs.tests -c $(_BuildConfig) -rc Checked $(_nativeSanitizersArg) /p:ArchiveTests=true
102+
timeoutInMinutes: 360
103+
# Hard-code queues here as we don't want to run on pre Win-10 queues
104+
# and we don't want to overcompilcate helix-queues-setup.yml just for this case.
105+
helixQueues:
106+
- Windows.Amd64.Server2022.Open
107+
- Windows.11.Amd64.Client.Open
108+
# extra steps, run tests
109+
postBuildSteps:
110+
- template: /eng/pipelines/libraries/helix.yml
111+
parameters:
112+
creator: dotnet-bot
113+
testRunNamePrefixSuffix: Libraries_$(_BuildConfig)
114+
scenarios:
115+
- normal
116+
84117
#
85118
# NativeAOT release build and smoke tests with AddressSanitizer
86119
#
@@ -92,6 +125,7 @@ extends:
92125
platforms:
93126
- linux_x64
94127
- osx_x64
128+
- windows_x64
95129
variables:
96130
- name: _nativeSanitizersArg
97131
value: -fsanitize address

eng/testing/linker/project.csproj.template

+4
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,8 @@
9898

9999
<Import Project="{NativeSanitizersTargets}" />
100100

101+
<ItemGroup>
102+
<Content Include="@(SanitizerRuntimeToCopy->'{SanitizerRuntimeFolder}/%(Identity)')" CopyToOutputDirectory="PreserveNewest" />
103+
</ItemGroup>
104+
101105
</Project>

eng/testing/linker/trimmingTests.targets

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@
119119
.Replace('{MicrosoftNetCoreAppRuntimePackDir}', '$(MicrosoftNetCoreAppRuntimePackDir)')
120120
.Replace('{NativeSanitizersTargets}', '$(RepositoryEngineeringDir)nativeSanitizers.targets')
121121
.Replace('{AppHostSourcePath}', '$(AppHostSourcePath)')
122-
.Replace('{SingleFileHostSourcePath}', '$(SingleFileHostSourcePath)'))"
122+
.Replace('{SingleFileHostSourcePath}', '$(SingleFileHostSourcePath)')
123+
.Replace('{SanitizerRuntimeFolder}', '$(DotNetHostBinDir)'))"
123124
Overwrite="true" />
124125
<Copy SourceFiles="$(_projectSourceFile);
125126
@(_additionalProjectSourceFiles)"

src/coreclr/pgosupport.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function(add_pgo TargetName)
3838
endif()
3939
endif(UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELEASE OR UPPERCASE_CMAKE_BUILD_TYPE STREQUAL RELWITHDEBINFO)
4040
endif(CLR_CMAKE_HOST_WIN32)
41-
elseif(CLR_CMAKE_PGO_OPTIMIZE)
41+
elseif(CLR_CMAKE_PGO_OPTIMIZE AND NOT CLR_CMAKE_ENABLE_SANITIZERS)
4242
if(CLR_CMAKE_HOST_WIN32)
4343
set(ProfileFileName "${TargetName}.pgd")
4444
else(CLR_CMAKE_HOST_WIN32)

src/tests/readytorun/tests/mainv1.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<CrossGenTest>false</CrossGenTest>
66
<!-- https://github.com/dotnet/runtime/issues/73138 -->
77
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
8+
<!-- 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. -->
9+
<CLRTestTargetUnsupported Condition="'$(EnableNativeSanitizers)' != ''">true</CLRTestTargetUnsupported>
810
</PropertyGroup>
911
<ItemGroup>
1012
<ProjectReference Include="fieldgetter.ilproj" />
@@ -156,7 +158,7 @@ export DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun
156158
]]></CLRTestBashPreCommands>
157159
</PropertyGroup>
158160

159-
<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build">
161+
<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build" Condition="'$(CLRTestTargetUnsupported)' != 'true'">
160162
<PropertyGroup>
161163
<TestAssemblyName>test.dll</TestAssemblyName>
162164
<TestAssemblySourcePath>$(OutputPath)/../testv1/test/</TestAssemblySourcePath>

src/tests/readytorun/tests/mainv2.csproj

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
<CrossGenTest>false</CrossGenTest>
66
<!-- https://github.com/dotnet/runtime/issues/73954 -->
77
<IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
8+
<!-- 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. -->
9+
<CLRTestTargetUnsupported Condition="'$(EnableNativeSanitizers)' != ''">true</CLRTestTargetUnsupported>
810
</PropertyGroup>
911
<ItemGroup>
1012
<ProjectReference Include="fieldgetter.ilproj" />
@@ -158,7 +160,7 @@ export DOTNET_GCName DOTNET_GCStress DOTNET_HeapVerify DOTNET_ReadyToRun
158160
]]></CLRTestBashPreCommands>
159161
</PropertyGroup>
160162

161-
<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build">
163+
<Target Name="CopyTestAssemblyToOutputs" AfterTargets="Build" Condition="'$(CLRTestTargetUnsupported)' != 'true'">
162164
<PropertyGroup>
163165
<TestAssemblyName>test.dll</TestAssemblyName>
164166
<TestV1AssemblySourcePath>$(OutputPath)/../testv1/test/</TestV1AssemblySourcePath>

0 commit comments

Comments
 (0)