Skip to content

Conversation

@gbalykov
Copy link
Member

@gbalykov gbalykov commented Apr 2, 2021

  • Exception can be thrown if native library is not found (this is the case if multicorejit is used with crossgen2, where Internal.JitInterface.CorInfoImpl.jitStartup and Internal.JitInterface.CorInfoImpl.getJit have "clrjitilc" native library, which is subtituted with correct library name during execution of crossgen2)
  • Assert _ASSERTE(pModule->IsSystem()) can be hit in AssertMulticoreJitAllowedModule if cctor is triggered at P/Invoke link time (IsClassConstructorTriggeredAtLinkTime()), skip such methods

cc @alpencolt

- Exception can be thrown if native library is not found (this is the case if multicorejit is used with crossgen2, where Internal.JitInterface.CorInfoImpl.jitStartup and Internal.JitInterface.CorInfoImpl.getJit have "clrjitilc" native library, which is subtituted with correct library name during execution of crossgen2)
- Assert _ASSERTE(pModule->IsSystem()) can be hit in AssertMulticoreJitAllowedModule if cctor is triggered at P/Invoke link time (IsClassConstructorTriggeredAtLinkTime()), skip such methods
@ghost
Copy link

ghost commented Apr 2, 2021

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@jkotas
Copy link
Member

jkotas commented Apr 2, 2021

Exception can be thrown if native library is not found (this is the case if multicorejit is used with crossgen2, where Internal.JitInterface.CorInfoImpl.jitStartup and Internal.JitInterface.CorInfoImpl.getJit have "clrjitilc" native library, which is subtituted with correct library name during execution of crossgen2)

Would it be better to stop resolving the PInvoke targets on the background thread? Resolving the PInvoke targets can have bad side-effect and break applications.

@gbalykov
Copy link
Member Author

gbalykov commented Apr 5, 2021

@jkotas you mean that exception might happen in GetStubForInteropMethod and leave runtime in incorrect state? Or that even correctly finished GetStubForInteropMethod can lead to problems?

In my other PR #48326 I've disabled NDirect methods. I'll close this PR then.

@jkotas
Copy link
Member

jkotas commented Apr 11, 2021

Or that even correctly finished GetStubForInteropMethod can lead to problems?

Yes, even correctly finished GetStubForInteropMethod can lead to problems. The application can install callbacks that influence how the PInvoke targets get resolved. GetStubForInteropMethod executed by speculative background JIT can miss these callbacks. The proper fix for this issue would need to disable resolving the PInvoke targets on background thread, and resolved them on the foreground thread instead once the PInvoke method gets actually called.

In my other PR #48326 I've disabled NDirect methods. I'll close this PR then.

Sounds good to me.

@jkotas jkotas closed this Apr 11, 2021
@gbalykov
Copy link
Member Author

@jkotas thanks for detailed clarification!

@ghost ghost locked as resolved and limited conversation to collaborators May 11, 2021
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
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.

3 participants