Bug 25631

Summary: Mono throws OutOfMemoryException on Ubuntu but not OSX or Windows
Product: [Mono] Runtime Reporter: Ted <ted>
Component: GCAssignee: Bugzilla <bugzilla>
Severity: normal CC: mono-bugs+mono, mono-bugs+runtime, vargaz
Priority: ---    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Tags: Is this bug a regression?: ---
Last known good build:

Description Ted 2014-12-28 16:22:42 UTC
I am unsure whether this is a bug or a configuration problem, but I don't know how to go about finding a solution.

I have installed Mono on an Ubuntu server and "Hello World" is working, but a simplified application that does some array handling and runs without problem under Mono on OSX or Windows is giving:

    System.OutOfMemoryException: Out of memory.
      at (wrapper alloc) object:AllocVector (intptr,intptr)

It should not require more than a few MB of memory. The server has 4GB of RAM.

Running again under alloc profile gives a different exception:

    System.OverflowException: Number overflow.
      at (wrapper managed-to-native) object:__icall_wrapper_mono_array_new_specific (intptr,int)

The problem is inconsistent, sometimes the code runs once but then not a second time. Sometimes it doesn't work for the first time. Sometimes it fails in a different method but for the same reason.

The program and full output can be downloaded at http://dev.intelorca.co.uk/2014/gacj_allocproblem.zip It would be good to see if anyone else has problems running the program under mono (/linux) and can provide any insight on what the problem is. Any pointers to configuring Mono to run better on Ubuntu would also be helpful if it is a configuration problem.

The program should output "Cambridge Surprise Major" 128 times.
Comment 1 Zoltan Varga 2015-01-02 18:46:10 UTC
I get:
Unhandled Exception:
System.OutOfMemoryException: Out of memory.
  at (wrapper alloc) object:AllocVector (intptr,intptr)
  at GACJ.Ringing.Methods.MethodClassifier.DetermineCycles () [0x00000] in <filename unknown>:0 
  at GACJ.Ringing.Methods.MethodClassifier.Classify () [0x00000] in <filename unknown>:0 
  at GACJ.Ringing.Methods.MethodClassifier.Classify (GACJ.Ringing.Methods.Method method) [0x00000] in <filename unknown>:0 
  at GACJ.Ringing.Methods.Method.Classify () [0x00000] in <filename unknown>:0 
  at Test.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0 

The DetermineCycles () method tries to allocate a String[] array with length 4294967304.
Comment 2 Ted 2015-01-02 20:26:40 UTC
Thanks for trying it Zoltan,

4294967304 = 0x100000008

It should be allocating a size of 8, but bit 32 seems to be set...
What could be causing this to happen only on this particular platform and not necessarily the first time the code is run?
Comment 3 Zoltan Varga 2015-01-02 22:29:45 UTC
Fixed in mono master 9e03c10d8fefea9210ca015cf484e819623c0a1a.
Comment 4 Ted 2015-01-03 07:42:18 UTC
Thanks, I can confirm this fix has worked.