Bug 18925

Summary: bad code generation or corruption of data structures (OSX w/ LLVM)
Product: [Mono] Runtime Reporter: Jonathan Shore <jonathan.shore>
Component: JITAssignee: Bugzilla <bugzilla>
Status: RESOLVED FIXED    
Severity: normal CC: mono-bugs+mono, mono-bugs+runtime, vargaz
Priority: ---    
Version: 3.2.x   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS   
Tags: Is this bug a regression?: ---
Last known good build:
Attachments: test program + environment

Description Jonathan Shore 2014-04-10 09:25:58 UTC
Created attachment 6548 [details]
test program + environment

I am running mono 3.2.6 on osx (the official distribution, 32bit) and encountering a problem when optimized with LLVM.  I reduced a real application into the smallest possible form to elicit this behavior (included).  The nature of the problem is as follows:

- instantiate a class with a combination of doubles, longs and references
- inspect a long property on the class
- the value in the property does not match the value provided in the ctor

Depending on how the ctor was called, this will present a proper outcome or not.   The code works properly in both code paths with native JIT but fails with LLVM jit.

Note that this worked fine for me on linux (64 bit) and failed on osx (32bit).

The scenarios are as follows, 1st the context: 

	var time = 1114459100000L;
	var priorbar = new TrimmedBar (instrument, time, period, 66.755, 66.755, 66.755, 66.755, 0);

This scenario fails and throws the exception:

	var filler = new TrimmedBar (instrument, time, period, priorbar.Close, priorbar.Close, priorbar.Close, priorbar.Close, 0);
	if (filler.TimeStamp != time)
		throw new Exception ("impossible situation, property get/set mismatch: [" + time + " vs " + filler.TimeStamp + "]: " + filler);

the second scenario succeeds and does not throw an exception:

	var price = priorbar.Close;
	var filler = new TrimmedBar (instrument, time, period, price, price, price, price, 0);
	if (filler.TimeStamp != time)
		throw new Exception ("impossible situation, property get/set mismatch: [" + time + " vs " + filler.TimeStamp + "]: " + filler);

The test is included.  Can run the 1st code path with . run-fail and the second with . run-pass

Let me know if you need clarification.
Comment 1 Zoltan Varga 2014-04-12 19:21:20 UTC
I can reproduce this with:
Mono JIT compiler version 3.4.0 ((no/d4511ef Tue Mar 25 14:35:52 EDT 2014)
Comment 2 Zoltan Varga 2014-04-15 02:54:51 UTC
Should be fixed by in mono master 7e33fc7450aa9942e6aef1afa656010cec6bc0e0.
Comment 3 Jonathan Shore 2014-04-15 12:14:11 UTC
thanks!