forked from mono/mono
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[loader] LoadFrom of problematic images should reprobe
The "problematic images" are Windows-specific assemblies that are often included with applications that do not work on Mono, but for which Mono has its own implementation. Previously (9ec8ec5) we changed mono to deny loading problematic images using Assembly.Load or when one assembly references another and we find a problematic image using the usual assembly search. For Assembly.LoadFrom, we used to emit a warning and then load the assembly anyway. In this commit, we change the behavior: If Assembly.LoadFrom tries to open a problematic image, we will instead probe for an assembly of that name in the default context. That should eventually end up opening Mono's version of that assembly. Example: Suppose a problematic System.Runtime.InteropServices.RuntimeInformation.dll is in the application bin path: /home/user/myapp/bin 1. User code does (for whatever reason) Assembly.LoadFrom ("/home/user/myapp/bin/System.Runtime.InteropServices.RuntimeInformation.dll") 2. We find the image and try to open it; add it to the images absfpath to image hash; note that there are no binding redirects; but that it is a problematic image. We extract the assembly name ("System.Runtime.InteropServices.RuntimeInformation", version x.y.z.w and public key token 123456789a) from the problematic image. 3. We probe for "System.Runtime.InteropServices.RuntimeInformation version x.y.z.w public key token 123456789a" in the default context. 4. We find /home/user/myapp/bin/System.Runtime.InteropServices.RuntimeInformation.dll in the application bin path; we try to open it, we see it's already in the images hash, but it's a problematic image, and we're not in a loadfrom context (we re-probed with default!) so we keep probing 5. We find <prefix>/lib/mono/4.5/Facaded/System.Runtime.InteropServices.RuntimeInformation.dll, it's not a problematic image, so we open that and return it to (3) 6. We return to (2) and close the problematic image and return the good one instead. 7. Assembly.LoadFrom returns with the good image. Fixes mono#8726
- Loading branch information
1 parent
298aa78
commit 4652b6c
Showing
3 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters