Pass the default ALC gchandle to the v3 preload hook (#54686)
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Thu, 24 Jun 2021 20:56:12 +0000 (16:56 -0400)
committerGitHub <noreply@github.com>
Thu, 24 Jun 2021 20:56:12 +0000 (22:56 +0200)
commitdb9cfd2d35c0672cc841c63f431831af5f63da7d
tree3c667225f8ad1f9dd660219d2c40d83bcdf4d7dc
parentc88da2905317c0b199c5814594f1ea5d079e0760
Pass the default ALC gchandle to the v3 preload hook (#54686)

* Pass the default ALC gchandle to the v3 preload hook

Fixes crashes early during startup when the gchandle is then used by the hooks
to call mono API functions.  The default ALC exists, but its managed object
doesn't, so the gchandle target is null.  The mono APIs detect the the special
gchandle and resolve it to the default ALC

Example crash
https://gist.github.com/grendello/b4ab24587a055725cc5e1416b86ad7ca

* [alc] Assert that we never see a null target from a managed ALC gchandle
src/mono/mono/metadata/assembly-load-context.c
src/mono/mono/metadata/assembly.c