Bug 18619 - COM Interop Regression crash introduced between 3.0.12 and 3.1.1.
Summary: COM Interop Regression crash introduced between 3.0.12 and 3.1.1.
Status: RESOLVED NORESPONSE
Alias: None
Product: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: 3.2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-03-27 14:47 UTC by Tom Hindle
Modified: 2018-04-05 19:56 UTC (History)
6 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 NORESPONSE

Description Tom Hindle 2014-03-27 14:47:51 UTC
C# COM Interop code that works with mono 3.0.12 and earily now causes crashes with mono 3.1.1 and newer. (I've tested up to mono 3.2.8)

Caused by the following commit:

commit e3866aa09217c5fe86ef9fe8d3bba3a618bc3ec5
Author: Rodrigo Kumpera <kumpera@gmail.com>
Date:   Fri Jun 21 20:31:02 2013 -0400

    When compiling gshared code, always use the cached isinst/castclass as it's faster than the cached one.


It difficult to provide a small self contained test case, but I will attempt to describe the crash:


Give a COM object, SomeComObject, that implements in interfaces IOne and ITwo, where IOne has a SomeMethod method; 

The first time code like this is executed:

IOne someComObject = ....;
someComObject.SomeMethod();

The C++ COM objects SomeMethod is correctly called.

However if this same code is re-executed a second time on a different instance of SomeComObject, the call to someComObject.SomeMethod(); crashes. (somewhere in the emitted marshing code, it looks like).
What seems to be happening is that for the second call, mono is incorrectly attempting to call a method on ITwo.


On a test mono build I've reversed the patch for e3866aa09217c5fe86ef9fe8d3bba3a618bc3ec5 and it fixes the crash.
Comment 1 Zoltan Varga 2014-03-28 16:59:28 UTC
You can also run mono with -O=-gshared as a workaround.
Comment 2 Rodrigo Kumpera 2014-05-21 01:47:26 UTC
Does  -O=-gshared fix for you?
Comment 3 Tom Hindle 2014-05-21 09:11:33 UTC
Yes - Settings -O=-gshared does indeed prevent the crash.

This does appear to be a workaround however rather than fixing the bug.
Comment 4 Ludovic Henry 2018-01-24 21:00:08 UTC
Can you still reproduce with latest version of Mono? If so, could you please provide a test case that reproduce the issue? Thank you.
Comment 5 Ludovic Henry 2018-04-05 19:56:39 UTC
Please reopen if you can still reproduce. Thank you.