Unity 4.6.3f1. Mono runtime stack corruption?

Folks, I’m facing a very weird issue which arises only on Android device. Specifically, one of the int arguments passed to a method once passed to another nested method changes its value to some really weird value.

The code is something as follows:

public static uint GetRating(Item item, int level = 0) {
return (uint)(GetBaseRating(item, level) * GetRatingCoeff());
}

public static GetBaseRating(Item item, int level) {

}

Here’s what happens:

  1. Some code calls GetRating(item, 0);
  2. Inside GetRating variable level == 0, this was checked with the log
  3. When GetBaseRating is called, inside its scope level == 121679560 (or some other weird value)

After hours of pulling out my hair I simply changed arguments order of GetBaseOrder to this GetBaseRating(int level, Item item), and everything is just fine now!

I went a bit further and compared CIL opcodes for both versions of the code. But there is nothing suspicious.

I wonder if there’s some known issue and if there any ways to avoid such Mono runtime misbehaviour.

Unity 4.6.4p2 has “(655263) - Android: Fixed crash in Mono caused by invocation of wrong method”.
The bug is best described in Snapdragon 800 crashes with corrupt stack trace - Unity Engine - Unity Discussions and can lead to all sorts of weird behaviour.
If the problem still exists it would be best if you could file a bug report (Unity QA: Building quality with passion).