Fix mono_aot_plt_trampoline GC unsafe assumption. (#42685)
authormonojenkins <jo.shields+jenkins@xamarin.com>
Fri, 25 Sep 2020 14:46:32 +0000 (10:46 -0400)
committerGitHub <noreply@github.com>
Fri, 25 Sep 2020 14:46:32 +0000 (16:46 +0200)
commitdb0d25d8caf09b8019ccfdf270c502baffcfdd0f
tree4b14b55d6774e7be950d36935c2902ad8ac618a3
parentbafb24c06197948e9600837c2e4700df725600a7
Fix mono_aot_plt_trampoline GC unsafe assumption. (#42685)

managed->native wrapper does the following under coop:

enter gc safe
native call
exit gc safe

since enter/exit gc safe are icalls they will be called through PLT on AOT builds. First call through a PLT slot will resolve the function using mono_aot_plt_trampoline and it currently assumes GC safe mode, so when hit as part of resolving exit gc safe, it is called under GC safe mode.

This has not showed up to be an issue under coop AOT, but asserts when running under checked build.

Fix will make sure thread is in GC unsafe mode making sure assumption of GC unsafe mode holds.

Co-authored-by: lateralusX <lateralusX@users.noreply.github.com>
src/mono/mono/mini/mini-trampolines.c