Bug 39047 - Verify Mono doesn't use a reference assembly mscorlib.dll on startup and provide clear error
Summary: Verify Mono doesn't use a reference assembly mscorlib.dll on startup and prov...
Status: RESOLVED DUPLICATE of bug 42584
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Aleksey Kliger
URL:
Depends on:
Blocks:
 
Reported: 2016-02-23 15:52 UTC by Alexander Köplinger [MSFT]
Modified: 2016-08-24 08:50 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED DUPLICATE of bug 42584

Description Alexander Köplinger [MSFT] 2016-02-23 15:52:27 UTC
In the past we had some hard to diagnose issues like https://bugzilla.xamarin.com/show_bug.cgi?id=38813 where reference assemblies were inadvertently used during runtime.

We should add proper validation so that we abort early and with a nice error message when Mono tries to use reference assemblies instead of the implementation assemblies (whatever the cause is, because this is never valid during runtime).

Right now, we only run cil-strip on the implementation assemblies to generate the ref asms which just empties method bodies, so it could be a bit more difficult to tell the assemblies apart. But we should at least assert that some fundamental types in corlib have method bodies.

In the future, it might be a good idea to annotate our ref asms with the [ReferenceAssembly] attribute (see https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.referenceassemblyattribute(v=vs.110).aspx) so we could more easily detect and deny all reference assemblies.
Comment 1 Alexander Köplinger [MSFT] 2016-07-27 10:24:33 UTC
Issues like https://bugzilla.xamarin.com/show_bug.cgi?id=42584 (and numerous others) would be way easier to diagnose if we had this.

CoreCLR does the check here: https://github.com/dotnet/coreclr/blob/775003a4c72f0acc37eab84628fcef541533ba4e/src/vm/pefile.inl#L139-L148
Comment 2 Marek Safar 2016-08-24 08:50:16 UTC

*** This bug has been marked as a duplicate of bug 42584 ***