This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 35828 - Thread.CurrentThread doesn't return correct object in appdomain
Summary: Thread.CurrentThread doesn't return correct object in appdomain
Status: VERIFIED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: 4.2.0 (C6)
Hardware: PC Mac OS
: --- normal
Target Milestone: (C6SR1)
Assignee: Ludovic Henry
URL:
: 39178 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-11-12 22:21 UTC by Zoltan Varga
Modified: 2016-02-29 15:54 UTC (History)
9 users (show)

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


Attachments

Description Zoltan Varga 2015-11-12 22:21:45 UTC
Reproducible in 4.2/master.

Testcase:
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
using System;
using System.Threading;

public class WorkStateThread
{
public void Start()
{
m_thread = new Thread(ThreadProc);
m_thread.Start(Thread.CurrentThread);
m_thread.Join();
}

private void ThreadProc (object objData)
{
if (m_thread != Thread.CurrentThread)
throw new InvalidOperationException ("m_thread != Thread.CurrentThread");
}

Thread m_thread;
}

[Serializable]
class MainClass
{
	public void foo () {
		WorkStateThread ws = new WorkStateThread ();
		ws.Start ();
		Console.WriteLine ("Done");
	}

	public static void Main (string[] args) {
		AppDomain ad = AppDomain.CreateDomain ("foo");
		var o = new MainClass ();
		ad.DoCallBack (o.foo);
	}
}
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Comment 1 Alexis Christoforides 2015-11-13 17:44:01 UTC
This might be a related: https://bugzilla.xamarin.com/show_bug.cgi?id=35530
Comment 2 Zoltan Varga 2015-11-15 08:33:39 UTC
Fixed in mono master ea09193eb876a2020cb3e0ae72138b5f73774c06.
Comment 3 Martin Potter 2015-11-16 14:24:24 UTC
Thank you for fixing this quickly. Was this fix going to make its way into the 4.2 release (or is 4.2 shipping off of master)?
Comment 4 Rodrigo Kumpera 2015-11-16 14:25:43 UTC
We should schedule this bug for C6
Comment 5 Udham Singh 2015-11-24 13:42:29 UTC
I have checked this issue with latest master mono MonoFramework-MDK-4.3.0.2163.macos10.xamarin.universal_f82f4e84b1332d94e52be8258f37f6d623c0a2c3 with the help of code provided in bug description, and observed that the value of m_thread is equal to Thread.CurrentThread with this build.

I have also checked this with Cycle 6 mono MonoFramework-MDK-4.2.1.102.macos10.xamarin.x86_6dd2d0d52b8bc4262d67833f44bc1537c3d17a9e and with this I observed that value of m_thread is not equal to Thread.CurrentThread.

Screencast : http://www.screencast.com/t/W9cMfseGjkC

As of now I am closing this issue. Please let me know if I have to check something else.

Environment Info : 

=== Xamarin Studio ===

Version 5.10 (build 871)
Installation UUID: ce927b2a-2c07-44c5-b186-09cfdafba6dc
Runtime:
	Mono 4.3.0 (master/f82f4e8)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 403002163

=== Xamarin.Profiler ===

Version: 0.24.286.0
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Xamarin.Android ===

Version: 6.0.0.34 (Business Edition)
Android SDK: /Users/xamarin76/Desktop/android-sdk-macosx
	Supported Android versions:
		2.3    (API level 10)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)

SDK Tools Version: 24.4.1
SDK Platform Tools Version: 23.0.1
SDK Build Tools Version: 23

Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Xamarin Android Player ===

Version: 0.3.7
Location: /Applications/Xamarin Android Player.app

=== Apple Developer Tools ===

Xcode 7.1 (9079)
Build 7B91b

=== Xamarin.iOS ===

Version: 9.3.2.378 (Business Edition)
Hash: ac3fe9a
Branch: master
Build date: 2015-11-22 15:06:07-0500

=== Xamarin.Mac ===

Version: 2.4.0.109 (Business Edition)

=== Build Information ===

Release ID: 510000871
Git revision: 4e9c5abb5ffdae12ba02ac49da83f8b2011dbb88
Build date: 2015-11-12 06:02:54-05
Xamarin addins: 55007ed0e56436f385d8e26394a45be563abc7e8
Build lane: monodevelop-lion-cycle6

=== Operating System ===

Mac OS X 10.10.5
Darwin Xamarin76s-Mac-mini.local 14.5.0 Darwin Kernel Version 14.5.0
    Wed Jul 29 02:26:53 PDT 2015
    root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64
Comment 6 Brendan Zagaeski (Xamarin Support) 2015-12-08 23:40:12 UTC
## Status update for any users CC'd on the bug

The candidate fix for this issue is not yet included in the preliminary Alpha version of "Cycle 6 – Service Release 1" published today, but that is mostly because those builds are still just early Alpha versions. The candidate fix will likely be included in a future preview version of "Cycle 6 – Service Release 1."
Comment 7 Ludovic Henry 2016-02-29 15:54:14 UTC
*** Bug 39178 has been marked as a duplicate of this bug. ***

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