Skip to content

Commit 65b29b5

Browse files
committed
Merge in 'release/6.0' changes
2 parents 9089a02 + 7a62f17 commit 65b29b5

80 files changed

Lines changed: 1767 additions & 214 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

eng/Versions.props

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<MajorVersion>6</MajorVersion>
77
<MinorVersion>0</MinorVersion>
88
<PatchVersion>3</PatchVersion>
9-
<SdkBandVersion>6.0.100</SdkBandVersion>
9+
<SdkBandVersion>6.0.200</SdkBandVersion>
1010
<PreReleaseVersionLabel>servicing</PreReleaseVersionLabel>
1111
<PreReleaseVersionIteration>
1212
</PreReleaseVersionIteration>
@@ -23,6 +23,10 @@
2323
<UsingToolXliff>false</UsingToolXliff>
2424
<LastReleasedStableAssemblyVersion>$(AssemblyVersion)</LastReleasedStableAssemblyVersion>
2525
</PropertyGroup>
26+
<ItemGroup>
27+
<!-- The bands we want to produce workload manifests for -->
28+
<WorkloadSdkBandVersions Include="6.0.100;6.0.200" />
29+
</ItemGroup>
2630
<PropertyGroup>
2731
<!-- For source generator support we need to target multiple versions of Rolsyn in order to be able to run on older versions of Roslyn -->
2832
<MicrosoftCodeAnalysisCSharpWorkspacesVersion_3_11>3.11.0</MicrosoftCodeAnalysisCSharpWorkspacesVersion_3_11>
@@ -145,7 +149,7 @@
145149
<SQLitePCLRawbundle_greenVersion>2.0.4</SQLitePCLRawbundle_greenVersion>
146150
<MoqVersion>4.12.0</MoqVersion>
147151
<FsCheckVersion>2.14.3</FsCheckVersion>
148-
<SdkVersionForWorkloadTesting>6.0.100-rtm.21480.21</SdkVersionForWorkloadTesting>
152+
<SdkVersionForWorkloadTesting>6.0.200-preview.22055.18</SdkVersionForWorkloadTesting>
149153
<!-- Docs -->
150154
<MicrosoftPrivateIntellisenseVersion>6.0.0-preview-20211019.1</MicrosoftPrivateIntellisenseVersion>
151155
<!-- ILLink -->

eng/pipelines/runtime-staging.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,51 @@ jobs:
9999
eq(variables['monoContainsChange'], true),
100100
eq(variables['isFullMatrix'], true))
101101
102+
#
103+
# MacCatalyst interp - requires AOT Compilation and Interp flags
104+
# Build the whole product using Mono and run libraries tests
105+
# The test app is built with the App Sandbox entitlement
106+
#
107+
- template: /eng/pipelines/common/platform-matrix.yml
108+
parameters:
109+
jobTemplate: /eng/pipelines/common/global-build-job.yml
110+
helixQueuesTemplate: /eng/pipelines/libraries/helix-queues-setup.yml
111+
buildConfig: Release
112+
runtimeFlavor: mono
113+
platforms:
114+
- MacCatalyst_x64
115+
# don't run tests on arm64 PRs until we can get significantly more devices
116+
- ${{ if eq(variables['isFullMatrix'], true) }}:
117+
- MacCatalyst_arm64
118+
variables:
119+
# map dependencies variables to local variables
120+
- name: librariesContainsChange
121+
value: $[ dependencies.evaluate_paths.outputs['SetPathVars_libraries.containsChange'] ]
122+
- name: monoContainsChange
123+
value: $[ dependencies.evaluate_paths.outputs['SetPathVars_mono.containsChange'] ]
124+
jobParameters:
125+
testGroup: innerloop
126+
nameSuffix: AllSubsets_Mono_AppSandbox
127+
buildArgs: -s mono+libs+host+packs+libs.tests -c $(_BuildConfig) /p:ArchiveTests=true /p:DevTeamProvisioning=adhoc /p:RunAOTCompilation=true /p:MonoForceInterpreter=true /p:BuildDarwinFrameworks=true /p:EnableAppSandbox=true
128+
timeoutInMinutes: 180
129+
condition: >-
130+
or(
131+
eq(dependencies.evaluate_paths.outputs['SetPathVars_libraries.containsChange'], true),
132+
eq(dependencies.evaluate_paths.outputs['SetPathVars_mono.containsChange'], true),
133+
eq(dependencies.evaluate_paths.outputs['SetPathVars_installer.containsChange'], true),
134+
eq(variables['isFullMatrix'], true))
135+
# extra steps, run tests
136+
extraStepsTemplate: /eng/pipelines/libraries/helix.yml
137+
extraStepsParameters:
138+
creator: dotnet-bot
139+
interpreter: true
140+
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
141+
condition: >-
142+
or(
143+
eq(variables['librariesContainsChange'], true),
144+
eq(variables['monoContainsChange'], true),
145+
eq(variables['isFullMatrix'], true))
146+
102147
#
103148
# MacCatalyst interp - requires AOT Compilation and Interp flags
104149
# Build the whole product using Mono and run libraries tests

eng/testing/tests.mobile.targets

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@
219219
MainLibraryFileName="$(MainLibraryFileName)"
220220
ForceAOT="$(RunAOTCompilation)"
221221
ForceInterpreter="$(MonoForceInterpreter)"
222+
EnableAppSandbox="$(EnableAppSandbox)"
222223
InvariantGlobalization="$(InvariantGlobalization)"
223224
UseConsoleUITemplate="True"
224225
GenerateXcodeProject="$(GenerateXcodeProject)"

src/libraries/Common/src/Interop/OSX/Interop.libproc.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ internal static partial class libproc
2525
// Constants from sys\resource.h
2626
private const int RUSAGE_INFO_V3 = 3;
2727

28+
// Constants from sys/errno.h
29+
private const int EPERM = 1;
30+
2831
// Defines from proc_info.h
2932
internal enum ThreadRunState
3033
{
@@ -120,7 +123,14 @@ internal static unsafe int[] proc_listallpids()
120123
{
121124
// Get the number of processes currently running to know how much data to allocate
122125
int numProcesses = proc_listallpids(null, 0);
123-
if (numProcesses <= 0)
126+
if (numProcesses == 0 && Marshal.GetLastPInvokeError() == EPERM)
127+
{
128+
// An app running in App Sandbox does not have permissions to list other running processes
129+
// and so the `proc_listallpids` function returns 0 and sets errno to 1. As a fallback
130+
// we return at least an array with the PID of the current process which we always know.
131+
return new[] { Environment.ProcessId };
132+
}
133+
else if (numProcesses <= 0)
124134
{
125135
throw new Win32Exception(SR.CantGetAllPids);
126136
}

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Unix.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ public static partial class PlatformDetection
4141
public static bool IsMacOsCatalinaOrHigher => IsOSX && Environment.OSVersion.Version >= new Version(10, 15);
4242
public static bool IsMacOsAppleSilicon => IsOSX && IsArm64Process;
4343
public static bool IsNotMacOsAppleSilicon => !IsMacOsAppleSilicon;
44+
public static bool IsAppSandbox => Environment.GetEnvironmentVariable("APP_SANDBOX_CONTAINER_ID") != null;
45+
public static bool IsNotAppSandbox => !IsAppSandbox;
4446

4547
// RedHat family covers RedHat and CentOS
4648
public static bool IsRedHatFamily => IsRedHatFamilyAndVersion();

src/libraries/Native/Unix/Common/pal_config.h.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#cmakedefine01 HAVE_F_FULLFSYNC
1313
#cmakedefine01 HAVE_O_CLOEXEC
1414
#cmakedefine01 HAVE_GETIFADDRS
15+
#cmakedefine01 HAVE_IFADDRS
1516
#cmakedefine01 HAVE_UTSNAME_DOMAINNAME
1617
#cmakedefine01 HAVE_STAT64
1718
#cmakedefine01 HAVE_FORK

src/libraries/Native/Unix/System.Native/pal_interfaceaddresses.c

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
#include <stdlib.h>
1212
#include <sys/types.h>
1313
#include <assert.h>
14+
#if HAVE_IFADDRS || HAVE_GETIFADDRS
1415
#include <ifaddrs.h>
16+
#endif
17+
#if !HAVE_GETIFADDRS && TARGET_ANDROID
18+
#include <dlfcn.h>
19+
#include <pthread.h>
20+
#endif
1521
#include <net/if.h>
1622
#include <netinet/in.h>
1723
#include <string.h>
@@ -55,7 +61,6 @@
5561
#endif
5662
#endif
5763

58-
#if HAVE_GETIFADDRS
5964
// Convert mask to prefix length e.g. 255.255.255.0 -> 24
6065
// mask parameter is pointer to buffer where address starts and length is
6166
// buffer length e.g. 4 for IPv4 and 16 for IPv6.
@@ -95,14 +100,67 @@ static inline uint8_t mask2prefix(uint8_t* mask, int length)
95100

96101
return len;
97102
}
103+
104+
#if !HAVE_IFADDRS && TARGET_ANDROID
105+
// This structure is exactly the same as struct ifaddrs defined in ifaddrs.h but since the header
106+
// might not be available (e.g., in bionics used in Android before API 24) we need to mirror it here
107+
// so that we can dynamically load the getifaddrs function and use it.
108+
struct ifaddrs
109+
{
110+
struct ifaddrs *ifa_next;
111+
char *ifa_name;
112+
unsigned int ifa_flags;
113+
struct sockaddr *ifa_addr;
114+
struct sockaddr *ifa_netmask;
115+
union
116+
{
117+
struct sockaddr *ifu_broadaddr;
118+
struct sockaddr *ifu_dstaddr;
119+
} ifa_ifu;
120+
void *ifa_data;
121+
};
122+
#endif
123+
124+
#if !HAVE_GETIFADDRS && TARGET_ANDROID
125+
// Try to load the getifaddrs and freeifaddrs functions manually.
126+
// This workaround is necessary on Android prior to API 24 and it can be removed once
127+
// we drop support for earlier Android versions.
128+
static int (*getifaddrs)(struct ifaddrs**) = NULL;
129+
static void (*freeifaddrs)(struct ifaddrs*) = NULL;
130+
131+
static void try_loading_getifaddrs()
132+
{
133+
void *libc = dlopen("libc.so", RTLD_NOW);
134+
if (libc)
135+
{
136+
getifaddrs = (int (*)(struct ifaddrs**)) dlsym(libc, "getifaddrs");
137+
freeifaddrs = (void (*)(struct ifaddrs*)) dlsym(libc, "freeifaddrs");
138+
}
139+
}
140+
141+
static bool ensure_getifaddrs_is_loaded()
142+
{
143+
static pthread_once_t getifaddrs_is_loaded = PTHREAD_ONCE_INIT;
144+
pthread_once(&getifaddrs_is_loaded, try_loading_getifaddrs);
145+
return getifaddrs != NULL && freeifaddrs != NULL;
146+
}
98147
#endif
99148

100149
int32_t SystemNative_EnumerateInterfaceAddresses(void* context,
101150
IPv4AddressFound onIpv4Found,
102151
IPv6AddressFound onIpv6Found,
103152
LinkLayerAddressFound onLinkLayerFound)
104153
{
105-
#if HAVE_GETIFADDRS
154+
#if !HAVE_GETIFADDRS && TARGET_ANDROID
155+
// Workaround for Android API < 24
156+
if (!ensure_getifaddrs_is_loaded())
157+
{
158+
errno = ENOTSUP;
159+
return -1;
160+
}
161+
#endif
162+
163+
#if HAVE_GETIFADDRS || TARGET_ANDROID
106164
struct ifaddrs* headAddr;
107165
if (getifaddrs(&headAddr) == -1)
108166
{
@@ -235,7 +293,7 @@ int32_t SystemNative_EnumerateInterfaceAddresses(void* context,
235293
freeifaddrs(headAddr);
236294
return 0;
237295
#else
238-
// Not supported on e.g. Android. Also, prevent a compiler error because parameters are unused
296+
// Not supported. Also, prevent a compiler error because parameters are unused
239297
(void)context;
240298
(void)onIpv4Found;
241299
(void)onIpv6Found;
@@ -247,7 +305,16 @@ int32_t SystemNative_EnumerateInterfaceAddresses(void* context,
247305

248306
int32_t SystemNative_GetNetworkInterfaces(int32_t * interfaceCount, NetworkInterfaceInfo **interfaceList, int32_t * addressCount, IpAddressInfo **addressList )
249307
{
250-
#if HAVE_GETIFADDRS
308+
#if !HAVE_GETIFADDRS && TARGET_ANDROID
309+
// Workaround for Android API < 24
310+
if (!ensure_getifaddrs_is_loaded())
311+
{
312+
errno = ENOTSUP;
313+
return -1;
314+
}
315+
#endif
316+
317+
#if HAVE_GETIFADDRS || TARGET_ANDROID
251318
struct ifaddrs* head; // Pointer to block allocated by getifaddrs().
252319
struct ifaddrs* ifaddrsEntry;
253320
IpAddressInfo *ai;
@@ -453,7 +520,7 @@ int32_t SystemNative_GetNetworkInterfaces(int32_t * interfaceCount, NetworkInter
453520

454521
return 0;
455522
#else
456-
// Not supported on e.g. Android. Also, prevent a compiler error because parameters are unused
523+
// Not supported. Also, prevent a compiler error because parameters are unused
457524
(void)interfaceCount;
458525
(void)interfaceList;
459526
(void)addressCount;

src/libraries/Native/Unix/System.Security.Cryptography.Native.Android/pal_sslstream.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,13 +585,14 @@ AndroidCryptoNative_SSLStreamRead(SSLStream* sslStream, uint8_t* buffer, int32_t
585585

586586
if (rem > 0)
587587
{
588-
data = make_java_byte_array(env, rem);
588+
int32_t bytes_to_read = rem < length ? rem : length;
589+
data = make_java_byte_array(env, bytes_to_read);
589590
IGNORE_RETURN((*env)->CallObjectMethod(env, sslStream->appInBuffer, g_ByteBufferGet, data));
590591
ON_EXCEPTION_PRINT_AND_GOTO(cleanup);
591592
IGNORE_RETURN((*env)->CallObjectMethod(env, sslStream->appInBuffer, g_ByteBufferCompact));
592593
ON_EXCEPTION_PRINT_AND_GOTO(cleanup);
593-
(*env)->GetByteArrayRegion(env, data, 0, rem, (jbyte*)buffer);
594-
*read = rem;
594+
(*env)->GetByteArrayRegion(env, data, 0, bytes_to_read, (jbyte*)buffer);
595+
*read = bytes_to_read;
595596
ret = SSLStreamStatus_OK;
596597
}
597598
else

src/libraries/Native/Unix/configure.cmake

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ include(CheckStructHasMember)
77
include(CheckSymbolExists)
88
include(CheckTypeSize)
99
include(CheckLibraryExists)
10+
include(CheckFunctionExists)
1011

1112
# CMP0075 Include file check macros honor CMAKE_REQUIRED_LIBRARIES.
1213
if(POLICY CMP0075)
@@ -141,6 +142,18 @@ check_c_source_compiles(
141142
"
142143
HAVE_FLOCK64)
143144
145+
check_c_source_compiles(
146+
"
147+
#include <sys/types.h>
148+
#include <ifaddrs.h>
149+
int main(void)
150+
{
151+
struct ifaddrs ia;
152+
return 0;
153+
}
154+
"
155+
HAVE_IFADDRS)
156+
144157
check_symbol_exists(
145158
O_CLOEXEC
146159
fcntl.h
@@ -156,9 +169,8 @@ check_symbol_exists(
156169
fcntl.h
157170
HAVE_F_FULLFSYNC)
158171
159-
check_symbol_exists(
172+
check_function_exists(
160173
getifaddrs
161-
ifaddrs.h
162174
HAVE_GETIFADDRS)
163175
164176
check_symbol_exists(

0 commit comments

Comments
 (0)