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: NEW
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: 2014-05-21 09:11 UTC (History)
5 users (show)

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


Attachments

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.

Note You need to log in before you can comment on or make changes to this bug.