Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fix dotnet/corefx#29266 #17734

Merged
merged 1 commit into from
Apr 24, 2018
Merged

Fix dotnet/corefx#29266 #17734

merged 1 commit into from
Apr 24, 2018

Conversation

sdmaclea
Copy link

@sdmaclea sdmaclea commented Apr 23, 2018

@jkotas @adityamandaleeka Given I do not have a OSX platform to test. This is my proposed fix.

Fixes dotnet/corefx#29266

@jkotas
Copy link
Member

jkotas commented Apr 23, 2018

@dotnet-bot test Ubuntu x64 corefx_baseline
@dotnet-bot test Windows_NT x64 corefx_baseline

@jkotas
Copy link
Member

jkotas commented Apr 23, 2018

Nit: We try to have more descriptive commit titles than just "Fix #XXXXX". https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/contributing.md#commit-messages

@jkotas
Copy link
Member

jkotas commented Apr 23, 2018

(This should fix the x64 problem, but there is probably still problem on ARM64.)

@sdmaclea
Copy link
Author

sdmaclea commented Apr 23, 2018

(This should fix the x64 problem, but there is probably still problem on ARM64.)

Why arm64 only and not arm64, x86, and arm32? They are all treated the same now.

Also note Reflection.Emit.ILGeneration.Tests was already passing on Arm64 w/o this change

@jkotas
Copy link
Member

jkotas commented Apr 23, 2018

https://github.com/dotnet/coreclr/blob/master/src/vm/frames.h#L2960
https://github.com/dotnet/coreclr/blob/master/src/vm/stubhelpers.cpp#L1170

This is under _WIN64 ifdef that is true for ARM64.

I was not able to reproduce the MacOS failure locally. It is intermittent failure. I suspect that some of these paths are executed rarely, e.g. only when the GC runs while the PInvoke is executing.

@sdmaclea
Copy link
Author

Nit: We try to have more descriptive commit titles than just "Fix #XXXXX".

Descriptive names requires understanding. I thought this was a simple temporary revert and could not determine a better name. Now it looks like this is required for other reasons more or less permanently, I can come up with a better description.

@sdmaclea
Copy link
Author

@jkotas PTAL. Fixed commit message. Fixed arm64 to use shift left and or #1 also.

@@ -2256,6 +2256,11 @@ void NDirectStubLinker::DoNDirect(ILCodeStream *pcsEmit, DWORD dwStubFlags, Meth
// for managed-to-unmanaged CALLI that requires marshaling, the target is passed
// as the secret argument to the stub by GenericPInvokeCalliHelper (asmhelpers.asm)
EmitLoadStubContext(pcsEmit, dwStubFlags);
#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_)
Copy link
Member

Choose a reason for hiding this comment

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

Other places use _WIN64 around this, it may be nice to use it here as well.

@@ -2256,6 +2256,11 @@ void NDirectStubLinker::DoNDirect(ILCodeStream *pcsEmit, DWORD dwStubFlags, Meth
// for managed-to-unmanaged CALLI that requires marshaling, the target is passed
// as the secret argument to the stub by GenericPInvokeCalliHelper (asmhelpers.asm)
EmitLoadStubContext(pcsEmit, dwStubFlags);
#if defined(_TARGET_AMD64_) || defined(_TARGET_ARM64_)
// the secret arg has been shifted to left and ORed with 1 (see code:GenericPInvokeCalliHelper)
Copy link
Member

Choose a reason for hiding this comment

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

Tag the other places we have found that depend on this with see code:GenericPInvokeCalliHelper so that they can be discovered later if somebody wants to come back to this?

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

LGTM, modulo a few nits.

When _WIN64 is defined vm relies on the secret arg being
shifted left and orred with #1.

Revert part of changes from dotnet#17659 to fix dotnet/corefx#29266

Fix arm64 to match amd64

Simplify dllimport.cpp
@sdmaclea
Copy link
Author

Nits are fixed. Tests are passing.

@jkotas
Copy link
Member

jkotas commented Apr 24, 2018

Thanks!

@jkotas jkotas merged commit 5ebaadf into dotnet:master Apr 24, 2018
@sdmaclea sdmaclea deleted the corefx-29266 branch May 24, 2018 19:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reflection.Emit.ILGeneration.Tests test fails in CI for OSX
3 participants