Bug 18925 - bad code generation or corruption of data structures (OSX w/ LLVM)
Summary: bad code generation or corruption of data structures (OSX w/ LLVM)
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: JIT ()
Version: 3.2.x
Hardware: PC Mac OS
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-04-10 09:25 UTC by Jonathan Shore
Modified: 2014-04-15 12:14 UTC (History)
3 users (show)

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


Attachments
test program + environment (4.57 MB, application/x-bzip2)
2014-04-10 09:25 UTC, Jonathan Shore
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 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!