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.
Alias: None
Product: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: 3.2.x
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2014-03-27 14:47 UTC by Tom Hindle
Modified: 2018-01-24 21:00 UTC (History)
6 users (show)

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


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 = ....;

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.

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