Skip to content

Commit

Permalink
[linker] Fix "Linked Away" exceptions with Thread.CurrentPrincipal. Fix
Browse files Browse the repository at this point in the history
#7321 (#7510)

Keep 'CallContextSecurityData' around since it's quite small (and the
normal linker logic will be able to deal with it if unused) and allows
the use of `Thread.CurrentPrincipal`

Also add unit test.

Fix #7321
  • Loading branch information
spouliot authored Nov 28, 2019
1 parent 09c899c commit 845e757
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
20 changes: 20 additions & 0 deletions tests/linker/ios/link sdk/LinkSdkRegressionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Security.Permissions;
using System.Security.Principal;
using System.Threading;
using System.Xml;
using Mono.Data.Sqlite;
Expand Down Expand Up @@ -1115,5 +1116,24 @@ public void AsQueryable_Enumerable ()
var list = new List<string> { "hello hello" };
Assert.NotNull (list.AsQueryable ().GroupBy (x => x).FirstOrDefault ()?.FirstOrDefault (), "Enumerable");
}

public class CustomIdentity : IIdentity {
public string AuthenticationType => "test";
public bool IsAuthenticated => true;
public string Name => "abc";
}

public class CustomPrincipal : IPrincipal {
public IIdentity Identity => new CustomIdentity ();
public bool IsInRole (string role) => true;
}

[Test]
// https://github.com/xamarin/xamarin-macios/issues/7321
public void Principal ()
{
Thread.CurrentPrincipal = new CustomPrincipal ();
Assert.That (Thread.CurrentPrincipal.Identity.Name, Is.EqualTo ("abc"), "Name");
}
}
}
10 changes: 8 additions & 2 deletions tools/linker/MonoTouch.Tuner/RemoveCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,14 @@ static bool IsCandidate (TypeDefinition type)
case "System.Runtime.Remoting.Proxies":
return true;
case "System.Runtime.Remoting.Messaging":
return type.Name != "AsyncResult" && type.Name != "LogicalCallContext"
&& type.Name != "MonoMethodMessage";
switch (type.Name) {
case "AsyncResult":
case "CallContextSecurityData":
case "LogicalCallContext":
case "MonoMethodMessage":
return false;
}
return true;
case "System.Security.AccessControl":
case "System.Security.Permissions":
case "System.Security.Policy":
Expand Down

9 comments on commit 845e757

@xamarin-release-manager
Copy link
Collaborator

@xamarin-release-manager xamarin-release-manager commented on 845e757 Nov 28, 2019

Choose a reason for hiding this comment

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

✅ Device tests passed on iOS32b on Azure DevOps(iOS32b): Html Report

No tests selected.


Failure analysis

Failure to select the correct tests to be run, so no tests were executed. Fix in progress: #7493

Final verdict: 🤥

@xamarin-release-manager
Copy link
Collaborator

@xamarin-release-manager xamarin-release-manager commented on 845e757 Nov 28, 2019

Choose a reason for hiding this comment

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

Build was (probably) aborted

🔥 Jenkins job (on internal Jenkins) failed in stage(s) 'Test run, Test run' 🔥

Build succeeded
✅ Packages:

API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

1 tests failed, 163 tests passed.

Failed tests

  • monotouch-test/watchOS 32-bits - simulator/Debug: Crashed

Failure analysis

Final verdict: 🤥

@xamarin-release-manager

This comment was marked as outdated.

@xamarin-release-manager

This comment was marked as outdated.

@xamarin-release-manager
Copy link
Collaborator

@xamarin-release-manager xamarin-release-manager commented on 845e757 Nov 29, 2019

Choose a reason for hiding this comment

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

🔥 Device tests completed (Failed) on iOS on Azure DevOps(iOS): Html Report 🔥

Test results

7 tests failed, 106 tests passed.

Failed tests

  • monotouch-test/iOS Unified 64-bits - device/Debug (dynamic registrar): Failed
  • link all/iOS Unified 64-bits - device/Release: TimedOut
  • link all/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): TimedOut
  • link sdk/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): TimedOut
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/Release: TimedOut
  • [NUnit] Mono BCL tests group 2/iOS Unified 64-bits - device/AssemblyBuildTarget: SDK framework (release): TimedOut
  • [xUnit] Mono BCL tests group 3/iOS Unified 64-bits - device/AssemblyBuildTarget: dylib (debug): TimedOut

Failure analysis

Final verdict: 😡 (#7509 is a severe regression)

@xamarin-release-manager
Copy link
Collaborator

@xamarin-release-manager xamarin-release-manager commented on 845e757 Nov 30, 2019

Choose a reason for hiding this comment

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

🔥 Device tests completed (Failed) on TvOS on Azure DevOps(TvOS): Html Report 🔥

Test results

18 tests failed, 95 tests passed.

Failed tests

  • monotouch-test/tvOS - device/Debug: Failed
  • monotouch-test/tvOS - device/AssemblyBuildTarget: dylib (debug): Failed
  • monotouch-test/tvOS - device/AssemblyBuildTarget: SDK framework (debug): Failed
  • monotouch-test/tvOS - device/AssemblyBuildTarget: dylib (debug, profiling): Failed
  • monotouch-test/tvOS - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • monotouch-test/tvOS - device/Release: Failed
  • monotouch-test/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed
  • monotouch-test/tvOS - device/Debug (dynamic registrar): Failed
  • monotouch-test/tvOS - device/Release (all optimizations): Failed
  • monotouch-test/tvOS - device/Debug (all optimizations): Failed
  • monotouch-test/tvOS - device/Debug: SGenConc: Failed
  • monotouch-test/tvOS - device/Debug (interpreter): Failed
  • monotouch-test/tvOS - device/Debug (interpreter -mscorlib): Failed
  • monotouch-test/tvOS - device/Release (interpreter -mscorlib): Failed
  • link all/tvOS - device/Release: TimedOut
  • link all/tvOS - device/AssemblyBuildTarget: SDK framework (release): TimedOut
  • [NUnit] Mono BCL tests group 2/tvOS - device/Release: TimedOut (MT1032: This application executable might be too large (984 MB) to execute on device. If bitcode was enabled you might want to disable it for development, it is only required to submit applications to Apple.)
  • [NUnit] Mono BCL tests group 2/tvOS - device/AssemblyBuildTarget: SDK framework (release): TimedOut

Failure analysis

Final verdict: 😡 (#7509 is a severe regression)

@xamarin-release-manager
Copy link
Collaborator

@xamarin-release-manager xamarin-release-manager commented on 845e757 Nov 30, 2019

Choose a reason for hiding this comment

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

❌ Status for 'xamarin-macios - sample testing (build)': failure.

  • ✅ Debug_iPhone_AF: Succeeded
  • ✅ Debug_iPhone_GR: Succeeded
  • ✅ Debug_iPhone_SZ: Succeeded
  • ✅ Debug_iPhoneSimulator: Succeeded
  • ✅ Release_iPhone_AF: Succeeded
  • ✅ Release_iPhone_GR: Succeeded
  • ✅ Release_iPhone_SZ: Succeeded
  • ❌ Release_iPhoneSimulator: Failed
  • ✅ Debug_Mac: Succeeded
  • ✅ Release_Mac: Succeeded

Failure analysis

Final verdict: 🤥

@rolfbjarne
Copy link
Member

Choose a reason for hiding this comment

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

Setting state to success where context is continuous-integration/jenkins/branch.

Only 🤥 (gred) issues found.

@rolfbjarne
Copy link
Member

Choose a reason for hiding this comment

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

Setting state to success where context is xamarin-macios - sample testing (build).

Only 🤥 (gred) issues found.

Please sign in to comment.