Bug 13544 - --enable-big-arrays is broken
Summary: --enable-big-arrays is broken
Alias: None
Product: Runtime
Classification: Mono
Component: GC ()
Version: master
Hardware: PC All
: --- minor
Target Milestone: Community
Assignee: Bugzilla
Depends on:
Reported: 2013-07-28 15:17 UTC by Steffen Kieß
Modified: 2018-01-19 18:45 UTC (History)
6 users (show)

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 for Bug 13544 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Steffen Kieß 2013-07-28 15:17:41 UTC
The range checks in the newarr instruction don't work and the size value is converted to int32 at some point (even with --enable-big-arrays).

Test case:

using System;
public class A {
  public static void CheckAlloc (long l) {
    try {
      Console.WriteLine (new byte[l].LongLength);
    } catch (Exception e) {
      Console.WriteLine (e.Message);
  public static void Main () {
    CheckAlloc (5000000000);
    CheckAlloc (4000000000);
    CheckAlloc (-1);
    CheckAlloc (-4000000000);
    CheckAlloc (-6000000000);

Result on current master with --enable-big-arrays:

Result on current master without --enable-big-arrays:
Number overflow.
Number overflow.
Number overflow.

Expected result with --enable-big-arrays:
Number overflow.
Number overflow.
Number overflow.

Expected result without --enable-big-arrays:
Number overflow.
Number overflow.
Number overflow.
Number overflow.
Number overflow.
Comment 1 Zoltan Varga 2013-07-28 21:08:48 UTC
Fixed the overflow checking in the normal case, --enable-big-arrays still remains broken.
Comment 2 Robert van der Boon 2016-03-08 13:23:57 UTC
Not sure if this is related to --enable-big-arrays or not, but the LongLength should never return negative numbers.
At the very least the LongLength property could be changed from
return Length;
return (long)(uint)Length;
which would solve some problems with multi-dimensional arrays as well:
now "new byte[int.MaxValue/2,4].LongLength" returns -4 instead of uint.MaxValue-4.
Comment 3 Ludovic Henry 2018-01-19 18:45:04 UTC
I can reproduce with Mono (master/117468d740a) compiled with `--enable-big-arrays`

The output I get is the following:
> Arithmetic operation resulted in an overflow.
> Arithmetic operation resulted in an overflow.
> Arithmetic operation resulted in an overflow.
> Arithmetic operation resulted in an overflow.
> Arithmetic operation resulted in an overflow.