Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

[release/3.1] Port dotnet/runtime#32104 fix for Thread.CurrentPrincipal regression #42860

Merged

Conversation

eiriktsarpalis
Copy link
Member

@eiriktsarpalis eiriktsarpalis commented Feb 17, 2020

Backports a fix for issue dotnet/runtime#31717 which concerns a regression in the behaviour of the Thread.CurrentPrincipal property, introduced in 3.0.

This has already been fixed in .NET 5 (see dotnet/runtime#32104). This PR ports that fix down to release/3.1.

Customer Impact

Assigning a PrincipalPolicy to the current AppDomain results in the first thread correctly returning Thread.CurrentPrincipal. However it will consistently return null for any subsequent threads. There are no known workarounds to this issue.

Regression?

Functional regression between 2.1 and 3.0. Reported by 2 customers.

Testing

The .NET 5 fix at dotnet/runtime#32104 includes tests for the fix.

Risk

Moderate. The regression was introduced in an attempt to introduce new behaviour (i.e. flowing the principal with ExecutionContext), but this was broken in all but the most trivial scenaria (using just one thread). It is conceivable that fixing this might expose other problems, or in the very least break applications written against 3.0 that implicitly depend on the current behaviour of the property.

Code Reviewer

@jkotas

@jkotas
Copy link
Member

jkotas commented Feb 17, 2020

This fix is in CoreLib so it needs to be submitted to https://github.com/dotnet/coreclr repo first.

@eiriktsarpalis
Copy link
Member Author

Ah, almost forgot about the duplication there :-)

@eiriktsarpalis
Copy link
Member Author

Referencing dotnet/runtime#32104

@eiriktsarpalis eiriktsarpalis changed the title Fix AppDomain.SetPrincipalPolicy bug for new threads (#32104) [release/3.1] Port dotnet/runtime#32104 fix for Thread.CurrentPrincipal regression Feb 17, 2020
@danmoseley danmoseley added the Servicing-consider Issue for next servicing release review label Feb 17, 2020
* fix principal policy for new threads

Fixes #31717
@danmoseley danmoseley added Servicing-approved Approved for servicing release and removed Servicing-consider Issue for next servicing release review labels Feb 18, 2020
@danmoseley danmoseley added this to the 3.1.3 milestone Feb 18, 2020
@danmoseley
Copy link
Member

Approved, please get CR and CI green and @Anipik will merge (I believe deadline is end of day)

@Anipik
Copy link

Anipik commented Feb 18, 2020

@jkotas can you take a final look at the change ?

@Anipik Anipik merged commit 909897f into dotnet:release/3.1 Feb 18, 2020
@eiriktsarpalis eiriktsarpalis deleted the backport-appdomain-principal-fix branch February 18, 2020 18:45
@eiriktsarpalis
Copy link
Member Author

Shouldn't the coreclr fix be merged first?

@Anipik
Copy link

Anipik commented Feb 18, 2020

Shouldn't the coreclr fix be merged first?

Will the coreclr change fail the new tests ?

@jkotas
Copy link
Member

jkotas commented Feb 18, 2020

Yes, the new test will fail without the CoreCLR change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Threading Servicing-approved Approved for servicing release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants