Bug 9746 - Linker removes System.Diagnostics.ProcessModule, causing crash
Summary: Linker removes System.Diagnostics.ProcessModule, causing crash
Status: RESOLVED FIXED
Alias: None
Product: Xamarin.Mac
Classification: Desktop
Component: mmp ()
Version: 1.0.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2013-01-23 16:30 UTC by Rolf Bjarne Kvinge [MSFT]
Modified: 2013-01-24 11:10 UTC (History)
1 user (show)

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


Attachments
stacktrace.txt (12.35 KB, text/plain)
2013-01-23 16:30 UTC, Rolf Bjarne Kvinge [MSFT]
Details
bug9746.xml (249 bytes, text/xml)
2013-01-23 19:23 UTC, Sebastien Pouliot
Details


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 Developer Community or GitHub 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 FIXED

Description Rolf Bjarne Kvinge [MSFT] 2013-01-23 16:30:37 UTC
Created attachment 3274 [details]
stacktrace.txt

Repro:

* Enable linking (either sdk only or all).
* Add this to a sample project:

   Console.WriteLine (System.Diagnostics.Process.GetCurrentProcess ().MainModule.FileName);

* Run & watch it crash.
Comment 2 Sebastien Pouliot 2013-01-23 16:34:36 UTC
That's likely reflection-based without a corresponding rule (and never caught before since the API is not available in MonoTouch).
Comment 3 Rolf Bjarne Kvinge [MSFT] 2013-01-23 16:37:40 UTC
Native reflection this time:

https://github.com/mono/mono/blob/master/mono/metadata/process.c#L386
Comment 4 Sebastien Pouliot 2013-01-23 18:43:50 UTC
Yup, the old audit (summer 2011) done on mono 2.10 code base did not cover code outside MT. I'll review the 3.0 code base keeping both MT and XM in mind.
Comment 5 Sebastien Pouliot 2013-01-23 19:23:30 UTC
Created attachment 3275 [details]
bug9746.xml

In the mean time a workaround is to use the --xml=file options to tell the linker to keep those types intact.

To do this 

1. download the attachment and add it to your project

2. then go to:

   Project Options, Build, Mac OSX Packaging > Advanced > Advanaced Mono Bundling Options > Extra Arguments

3. add the following (add the path to the file if needed)

   --xml=bug9746.xml

4. rebuild
Comment 6 Sebastien Pouliot 2013-01-24 11:09:32 UTC
Fixed in ad63829a65e50cb5ae862cc93e5bd453d58e1a98
It will be available in 1.0.64+