Bug 15625 - Mono profiler changes execution of program in unexpected way
Summary: Mono profiler changes execution of program in unexpected way
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: General ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Alex Rønne Petersen
URL:
Depends on:
Blocks:
 
Reported: 2013-10-23 12:37 UTC by monobugs12
Modified: 2016-08-29 15:16 UTC (History)
4 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 FIXED

Description monobugs12 2013-10-23 12:37:12 UTC
Below program runs fine when the profiler is not used.

However, when running it with: 
  mono --profile=log Test.exe
the error below is generated.

mono -V gives:
Mono JIT compiler version 3.2.1 (Debian 3.2.1+dfsg-1~pre3+raring2)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug 
        LLVM:          supported, not enabled.
        GC:            sgen

Everthing works fine however on a different machine, with a different mono-version:
Mono JIT compiler version 3.2.1 (Debian 3.2.1+dfsg-1~pre2)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors.
www.mono-project.com
    TLS:           __thread
    SIGSEGV:       altstack
    Notifications: epoll
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug
    LLVM:          supported, not enabled.
    GC:            sgen



-------------------
the error message
-------------------
Unhandled Exception:
System.ArgumentException: Object is not a Test
  at Test.MainClass+Test.CompareTo (System.Object obj) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericCompare$cont@972-1 (Microsoft.FSharp.Core.GenericComparer comp, System.Object yobj, System.Object xobj, IComparable x, Microsoft.FSharp.Core.Unit unitVar) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericCompare (Microsoft.FSharp.Core.GenericComparer comp, System.Object xobj, System.Object yobj) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericComparisonWithComparerIntrinsic[Test] (IComparer comp, Test.Test x, Test.Test y) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericComparisonIntrinsic[Test] (Test.Test x, Test.Test y) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+-cctor@2180-1[Test.MainClass+Test].System-Collections-Generic-IComparer`1-Compare (Test.Test x, Test.Test y) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Collections.MapTreeModule.add[Test,Int32] (IComparer`1 comparer, Test.Test k, Int32 v, Microsoft.FSharp.Collections.MapTree`2 m) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Collections.FSharpMap`2[Test.MainClass+Test,System.Int32].Add (Test.Test key, Int32 value) [0x00000] in <filename unknown>:0 
  at Test.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: Object is not a Test
  at Test.MainClass+Test.CompareTo (System.Object obj) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericCompare$cont@972-1 (Microsoft.FSharp.Core.GenericComparer comp, System.Object yobj, System.Object xobj, IComparable x, Microsoft.FSharp.Core.Unit unitVar) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericCompare (Microsoft.FSharp.Core.GenericComparer comp, System.Object xobj, System.Object yobj) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericComparisonWithComparerIntrinsic[Test] (IComparer comp, Test.Test x, Test.Test y) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+HashCompare.GenericComparisonIntrinsic[Test] (Test.Test x, Test.Test y) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Core.LanguagePrimitives+-cctor@2180-1[Test.MainClass+Test].System-Collections-Generic-IComparer`1-Compare (Test.Test x, Test.Test y) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Collections.MapTreeModule.add[Test,Int32] (IComparer`1 comparer, Test.Test k, Int32 v, Microsoft.FSharp.Collections.MapTree`2 m) [0x00000] in <filename unknown>:0 
  at Microsoft.FSharp.Collections.FSharpMap`2[Test.MainClass+Test,System.Int32].Add (Test.Test key, Int32 value) [0x00000] in <filename unknown>:0 
  at Test.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 


------------
the program
------------
using System;
using System.Linq;
using Microsoft.FSharp.Collections;
using Microsoft.FSharp.Core;

namespace Test
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			var map = new FSharpMap<Test,int>(Enumerable.Empty<System.Tuple<Test,int>>());
			var x = map.Add(new Test(1),0);
			var y = x.Add(new Test(2),1);

			Console.WriteLine(y); 
		}

		public class Test : IComparable
		{
			int Number;

			public Test(int i)
			{
				Number = i;
			}

			public int CompareTo( object obj)
			{
				if (obj == null) return 1;

				Test otherTest = obj as Test;
				if (otherTest != null) 
					return this.CompareTo(otherTest);
				else
					throw new ArgumentException("Object is not a Test");
			}


			public int CompareTo(Test other)
			{
				return this.Number.CompareTo(other.Number); 
			}

		}
	}
}
Comment 1 monobugs12 2013-10-23 13:12:23 UTC
The version of mono below has the same problem as well:

Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-5ubuntu1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  x86
        Disabled:      none
        Misc:          softdebug 
        LLVM:          supported, not enabled.
        GC:            Included Boehm (with typed GC and Parallel Mark)
Comment 3 Andrea Canciani 2013-12-16 14:19:17 UTC
I cannot reproduce the issue on 1dcee202f49e73d13643946dfc569b70e1356ca9.
$ mono -V
Mono Runtime Engine version 3.2.7 (master/1dcee20 Mon Dec 16 10:21:35 CET 2013)
Comment 4 Alex Rønne Petersen 2016-08-29 15:16:58 UTC
There have been a ton of profiler fixes since this bug was filed, so chances are this has been fixed. Feel free to reopen if that's not the case, though.