Bug 3623 - Calling a native function that then calls into Managed code in another AppDomain does not restore the current appdomain upon return.
Summary: Calling a native function that then calls into Managed code in another AppDom...
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: Interop ()
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-02-23 19:06 UTC by Michael Mudge
Modified: 2012-03-11 13:34 UTC (History)
5 users (show)

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


Attachments
native code for linux .so (1.02 KB, application/x-zip-compressed)
2012-02-24 10:39 UTC, Eric Samsel
Details
native code for linux .so (1.01 KB, application/x-zip-compressed)
2012-02-24 10:41 UTC, Eric Samsel
Details
patch (5.59 KB, patch)
2012-02-27 19:20 UTC, Zoltan Varga
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 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 FIXED

Description Michael Mudge 2012-02-23 19:06:34 UTC
Per the C# file described here:

http://pastebin.com/D0WxnDXx

Managed function "OtherDomainTest" calls native from AppDomain 1.  Native makes a callback into AppDomain 0.  When the native returns to the original managed call, the current AppDomain in "OtherDomainTest" has unexpectedly switched to AppDomain 0.
Comment 1 Eric Samsel 2012-02-24 10:39:44 UTC
Created attachment 1415 [details]
native code for linux .so

I've attached the native code and build script that will allow the linked C# code to run and exhibit the bug. The build script will build and copy the .so to LD_LIBRARY_PATH so you should be able to run the C# assembly immediately.
Comment 2 Eric Samsel 2012-02-24 10:41:28 UTC
Created attachment 1416 [details]
native code for linux .so

typo in previous attachment
Comment 3 Zoltan Varga 2012-02-27 19:19:45 UTC
Please try the attached patch.
Comment 4 Zoltan Varga 2012-02-27 19:20:11 UTC
Created attachment 1429 [details]
patch
Comment 5 Zoltan Varga 2012-03-04 14:51:35 UTC
Fixed in master. Use the attached patch for 2.10.
Comment 6 Zoltan Varga 2012-03-06 14:38:41 UTC
The fix was broken and had to be reverted.
Comment 7 Zoltan Varga 2012-03-06 14:38:52 UTC
-> reopen.
Comment 8 Zoltan Varga 2012-03-11 13:34:09 UTC
Fixed in master/2.10. The 2.10 commits are:
e92c10fa703ce5f14e55ad76c05fb8338e0a223b
d9d2965c29e7dc45222b1f2b7057f2ea025ecbc6