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

[AppleAppBuilder] Entitlements to run tests on catalyst using the JIT #50637

Merged
5 commits merged into from
Apr 5, 2021

Conversation

lambdageek
Copy link
Member

@lambdageek lambdageek commented Apr 2, 2021

It still doesn't pass tests, but now it doesn't crash on startup

  1. Don't set the ICU_DAT_FILE_PATH since we're not bundling a static ICU. Fixes interpreter runs.
  2. If using the JIT, enable the hardened runtime and add two entitlements:
    a. the JITing entitlement - without it, we can't mmap MAP_JIT pages in catalyst apps
    b. the "disable library validation" entitlement - without it, we can't load the system libicu, or the in-bundle (but unsigned) libSystem.Native.dylib
  3. Update the iOS sample to run on Catalyst, too - using make run-catalyst

to use the JIT on MacCatalyst we need the hardened runtime and the JIT
entitlement.  Otherwise mmap() with a MAP_JIT argument fails with EINVAL.
To load libSystem.Native.dylib from the Resources/ directory in the .app
bundle.  (And possibly to load libicu from homebrew)
@ghost
Copy link

ghost commented Apr 2, 2021

Tagging subscribers to this area: @directhex
See info in area-owners.md if you want to be subscribed.

Issue Details

It still doesn't pass tests 😄

But now it doesn't crash on startup

  1. Use hardened runtime - and the JITing entitlement - without it, we can't mmap MAP_JIT pages in catalyst apps
  2. Use the "disable library validation" entitlement - without it, we can't load the system libicu, or the in-bundle (but unsigned) libSystem.Native.dylib
  3. Don't set the ICU_DAT_FILE_PATH since we're not bundling a static ICU.

Now the tests fail like this:

Xcode: /Users/alklig/work/dotnet-runtime/runtime/artifacts/bin/System.Buffers.Tests/net6.0-Debug/maccatalyst-x64/AppBundle/System.Buffers.Tests/System.Buffers.Tests.xcodeproj
  App: /Users/alklig/work/dotnet-runtime/runtime/artifacts/bin/System.Buffers.Tests/net6.0-Debug/maccatalyst-x64/AppBundle/System.Buffers.Tests/Release-maccatalyst/System.Buffers.Tests.app
  XHarness command issued: apple test --app=/Users/alklig/work/dotnet-runtime/runtime/artifacts/bin/System.Buffers.Tests/net6.0-Debug/maccatalyst-x64/AppBundle/System.Buffers.Tests/Release-maccatalyst/System.Buffers.Tests.app --targets=maccatalyst --xcode=/Applications/Xcode_12.4.app/Contents/Developer/../.. --output-directory=/Users/alklig/work/dotnet-runtime/runtime/artifacts/bin/System.Buffers.Tests/net6.0-Debug/maccatalyst-x64/AppBundle/xharness-output
  info: Preparing run for maccatalyst
  info: Getting app bundle information..
  info: Starting application 'System.Buffers.Tests' on maccatalyst
  info: Application finished the test run successfully with some failed tests
  info: Tests run: 85 Passed: 75 Inconclusive: 0 Failed: 8 Ignored: 2
  XHarness exit code: 1 (TESTS_FAILED)
  XHarness artifacts: /Users/alklig/work/dotnet-runtime/runtime/artifacts/bin/System.Buffers.Tests/net6.0-Debug/maccatalyst-x64/AppBundle/xharness-output
/Users/alklig/work/dotnet-runtime/runtime/eng/testing/tests.targets(117,5): error : One or more tests failed while running tests from 'System.Buffers.Tests'. [/Users/alklig/work/dotnet-runtime/runtime/src/libraries/System.Buffers/tests/System.Buffers.Tests.csproj]

Build FAILED.

/Users/alklig/work/dotnet-runtime/runtime/eng/testing/tests.targets(117,5): error : One or more tests failed while running tests from 'System.Buffers.Tests'. [/Users/alklig/work/dotnet-runtime/runtime/src/libraries/System.Buffers/tests/System.Buffers.Tests.csproj]
    0 Warning(s)
    1 Error(s)

the xml results file has stack traces like this one:

<message><![CDATA[System.ComponentModel.Win32Exception : Operation timed out]]></message>
          <stack-trace><![CDATA[   at System.Diagnostics.Process.EnsureInitialized()
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Microsoft.DotNet.RemoteExecutor.RemoteExecutor.Invoke(MethodInfo method, String[] args, RemoteInvokeOptions options, Boolean pasteArguments)
   at Microsoft.DotNet.RemoteExecutor.RemoteExecutor.Invoke(Action method, RemoteInvokeOptions options)
   at System.Buffers.ArrayPool.Tests.ArrayPoolTest.RemoteInvokeWithTrimming(Action action, Boolean trim)
   at System.Buffers.ArrayPool.Tests.ArrayPoolUnitTests.RentBufferFiresRentedDiagnosticEvent()
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)]]></stack-trace>

<table>
  <tr>
    <th align="left">Author:</th>
    <td>lambdageek</td>
  </tr>
  <tr>
    <th align="left">Assignees:</th>
    <td>-</td>
  </tr>
  <tr>
    <th align="left">Labels:</th>
    <td>

`area-Infrastructure-mono`

</td>
  </tr>
  <tr>
    <th align="left">Milestone:</th>
    <td>-</td>
  </tr>
</table>
</details>

@lambdageek
Copy link
Member Author

/cc @steveisok @directhex

@lambdageek
Copy link
Member Author

lambdageek commented Apr 2, 2021

I build the runtime with

$ ./build.sh --os MacCatalyst -s mono+libs -c Debug

and run the System.Buffers testsuite with

$ ./dotnet.sh build src/libraries/System.Buffers/tests /p:TargetOS=MacCatalyst /p:TargetArchitecture=x64 /t:Test /p:Configuration=Debug

Now the tests fail like this:

Xcode: /Users/alklig/work/dotnet-runtime/runtime/artifacts/bin/System.Buffers.Tests/net6.0-Debug/maccatalyst-x64/AppBundle/System.Buffers.Tests/System.Buffers.Tests.xcodeproj
  App: /Users/alklig/work/dotnet-runtime/runtime/artifacts/bin/System.Buffers.Tests/net6.0-Debug/maccatalyst-x64/AppBundle/System.Buffers.Tests/Release-maccatalyst/System.Buffers.Tests.app
  XHarness command issued: apple test --app=/Users/alklig/work/dotnet-runtime/runtime/artifacts/bin/System.Buffers.Tests/net6.0-Debug/maccatalyst-x64/AppBundle/System.Buffers.Tests/Release-maccatalyst/System.Buffers.Tests.app --targets=maccatalyst --xcode=/Applications/Xcode_12.4.app/Contents/Developer/../.. --output-directory=/Users/alklig/work/dotnet-runtime/runtime/artifacts/bin/System.Buffers.Tests/net6.0-Debug/maccatalyst-x64/AppBundle/xharness-output
  info: Preparing run for maccatalyst
  info: Getting app bundle information..
  info: Starting application 'System.Buffers.Tests' on maccatalyst
  info: Application finished the test run successfully with some failed tests
  info: Tests run: 85 Passed: 75 Inconclusive: 0 Failed: 8 Ignored: 2
  XHarness exit code: 1 (TESTS_FAILED)
  XHarness artifacts: /Users/alklig/work/dotnet-runtime/runtime/artifacts/bin/System.Buffers.Tests/net6.0-Debug/maccatalyst-x64/AppBundle/xharness-output
/Users/alklig/work/dotnet-runtime/runtime/eng/testing/tests.targets(117,5): error : One or more tests failed while running tests from 'System.Buffers.Tests'. [/Users/alklig/work/dotnet-runtime/runtime/src/libraries/System.Buffers/tests/System.Buffers.Tests.csproj]

Build FAILED.

/Users/alklig/work/dotnet-runtime/runtime/eng/testing/tests.targets(117,5): error : One or more tests failed while running tests from 'System.Buffers.Tests'. [/Users/alklig/work/dotnet-runtime/runtime/src/libraries/System.Buffers/tests/System.Buffers.Tests.csproj]
    0 Warning(s)
    1 Error(s)

the xml results file has stack traces like this one:

<message><![CDATA[System.ComponentModel.Win32Exception : Operation timed out]]></message>
          <stack-trace><![CDATA[   at System.Diagnostics.Process.EnsureInitialized()
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Microsoft.DotNet.RemoteExecutor.RemoteExecutor.Invoke(MethodInfo method, String[] args, RemoteInvokeOptions options, Boolean pasteArguments)
   at Microsoft.DotNet.RemoteExecutor.RemoteExecutor.Invoke(Action method, RemoteInvokeOptions options)
   at System.Buffers.ArrayPool.Tests.ArrayPoolTest.RemoteInvokeWithTrimming(Action action, Boolean trim)
   at System.Buffers.ArrayPool.Tests.ArrayPoolUnitTests.RentBufferFiresRentedDiagnosticEvent()
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)]]></stack-trace>

Use a list in the builder instead of hardcoding in the template.
@lambdageek lambdageek marked this pull request as ready for review April 2, 2021 15:26
@ghost
Copy link

ghost commented Apr 2, 2021

Hello @lambdageek!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost ghost merged commit b7a1648 into dotnet:main Apr 5, 2021
thaystg added a commit to thaystg/runtime that referenced this pull request Apr 6, 2021
…shim_mono

# By Aaron Robinson (10) and others
# Via GitHub
* upstream/main: (108 commits)
  [mbr] Add Apple sample (dotnet#50740)
  make EstablishProxyTunnelAsync throw on failure status code from proxy (dotnet#50763)
  Improve RGB Min Max evaluation performance by using 2 or 3 comparison… (dotnet#50622)
  [mono] More domain cleanups (dotnet#50479)
  Fix Crossgen2 of PlatformDefaultMemberFunction methods and calls. (dotnet#50754)
  Disable EventSource generator in design-time builds (dotnet#50741)
  Fix X509 test failures on Android (dotnet#50301)
  Do not confuse fgDispBasicBlocks in fgMorphBlocks (dotnet#50703)
  Enforce 64KB event payload size limit on EventPipe  (dotnet#50600)
  Reorganize CoreCLR native build to reduce CMake reconfigures when the build system is untouched (dotnet#49906)
  [mbr] Turn on hot reload for iOS, tvOS and MacCatalyst (dotnet#50458)
  improve connection scavenge logic by doing zero-byte read (dotnet#50545)
  Resolve call mdtokens when making tier 1 inline observations (dotnet#50675)
  Annotate APIs in System.Private.Xml (dotnet#49682)
  Support compiling against OpenSSL 3 headers
  Change Configuration.Json to use a regular Dictionary. (dotnet#50611)
  Remove unused BigNumFromBinary P/Invoke (dotnet#50670)
  Make Ninja the default CMake generator on Windows for the repo (dotnet#49715)
  [AppleAppBuilder] Entitlements to run tests on catalyst using the JIT (dotnet#50637)
  [mono] Fix delegate invokes to dynamic methods in mixed mode. (dotnet#50547)
  ...

# Conflicts:
#	src/mono/dlls/mscordbi/CMakeLists.txt
@ghost ghost locked as resolved and limited conversation to collaborators May 5, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants