Bug 6842 - mono 2.11.4 (head) crashes when using MONO_GC_PARAMS="major=marksweep-fixed,major-heap-size=2g"
Summary: mono 2.11.4 (head) crashes when using MONO_GC_PARAMS="major=marksweep-fixed,m...
Status: RESOLVED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: GC ()
Version: unspecified
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: Mark Probst
URL:
Depends on:
Blocks:
 
Reported: 2012-09-02 08:47 UTC by Jonathan Shore
Modified: 2012-09-06 14:07 UTC (History)
4 users (show)

Tags:
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 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 2012-09-02 08:47:05 UTC
I tried to give my heap (with sgen) a fixed size, but failed immediately with a segmentation fault.   I am using 2.11.4 (approximately, off of a build of the head 2 days ago)

export MONO_GC_PARAMS="major=marksweep-fixed,major-heap-size=2g"
mono --gc=sgen --llvm <file>

I turned on mono debug logging:

Mono: Assembly Loader probing location: '/opt/mono-2.11/lib/mono/4.5/mscorlib.dll'.
Mono: Image addref mscorlib[0xe98e10] -> /opt/mono-2.11/lib/mono/4.5/mscorlib.dll[0xe981f0]: 2
Mono: AOT module /opt/mono-2.11/lib/mono/4.5/mscorlib.dll.so is unusable: compiled against GC boehm, while the current runtime uses GC sgen.
.

Mono: Assembly Loader loaded assembly from location: '/opt/mono-2.11/lib/mono/4.5/mscorlib.dll'.
Mono: Config attempting to parse: '/opt/mono-2.11/lib/mono/4.5/mscorlib.dll.config'.
Mono: Config attempting to parse: '/opt/mono-2.11/etc/mono/assemblies/mscorlib/mscorlib.config'.
Segmentation fault

Without the MONO_GC_PARAMS, everything runs fine.
Comment 1 Miguel de Icaza [MSFT] 2012-09-02 12:33:06 UTC
Try deleting your AOT assemblies before you run.
Comment 2 Jonathan Shore 2012-09-02 13:06:23 UTC
I have not compiled with AOT.  Do you mean the prebuilt AOT assemblies in the mono install dirs?  I have not been using AOT at all, so this would just be the prebuilt from the standard mono build.

I can use sgen with the default parameterization with no problem (i.e. --gc=sgen).  It is only with these GC parameters that it falls over.  

AOT does not seem to be the likely cause. I get the same AOT related error messages when running --gc=sgen but without the GC parameters. 

Here is the start of the log with --gc=sgen --llvm, but without the MONO_GC_PARAMS.

Mono: Assembly Loader probing location: '/opt/mono-2.11/lib/mono/4.5/mscorlib.dll'.
Mono: Image addref mscorlib[0x2288e10] -> /opt/mono-2.11/lib/mono/4.5/mscorlib.dll[0x22881f0]: 2
Mono: AOT module /opt/mono-2.11/lib/mono/4.5/mscorlib.dll.so is unusable: compiled against GC boehm, while the current runtime uses GC sgen.
.

Mono: Assembly Loader loaded assembly from location: '/opt/mono2.11/lib/mono/4.5/mscorlib.dll'.
Mono: Config attempting to parse: '/opt/mono2.11/lib/mono/4.5/mscorlib.dll.config'.
Mono: Config attempting to parse: '/opt/mono-2.11/etc/mono/assemblies/mscorlib/mscorlib.config'.
Mono: GC_MINOR: (Nursery full) pause 0.13ms, total 0.13ms, bridge 0.00 promoted 48K major 64K los 0K
Mono: GC_MINOR: ((null)) pause 0.00ms, total 0.00ms, bridge 0.00 promoted 48K major 64K los 0K
Mono: GC_MAJOR: (Minor allowance) pause 0.04ms, total 0.04ms, bridge 0.00 major 80K/80K los 0K/0K
Mono: GC_MINOR: ((null)) pause 0.00ms, total 0.00ms, bridge 0.00 promoted 0K major 80K los 0K
Mono: GC_MINOR: (Nursery full) pause 0.07ms, total 0.07ms, bridge 0.00 promoted 96K major 192K los 0K
Mono: GC_MINOR: ((null)) pause 0.00ms, total 0.00ms, bridge 0.00 promoted 96K major 192K los 0K
Mono: GC_MINOR: (Nursery full) pause 0.01ms, total 0.01ms, bridge 0.00 promoted 0K major 192K los 0K
Mono: GC_MINOR: ((null)) pause 0.00ms, total 0.00ms, bridge 0.00 promoted 0K major 192K los 0K
Mono: Assembly mscorlib[0x2288e10] added to domain IndicatorLoader.exe, ref_count=1
Mono: Config attempting to parse: '/opt/mono-2.11/etc/mono/config'.
Mono: Config attempting to parse: '/home/jshore/.mono/config'.
Mono: Assembly Loader probing location: '/home/jshore/Dev/hf/lib/Debug/IndicatorLoader.exe'.
Mono: Image addref IndicatorLoader[0x235c4f0] -> /home/jshore/Dev/hf/lib/Debug/IndicatorLoader.exe[0x235bc40]: 2
Mono: Assembly IndicatorLoader[0x235c4f0] added to domain IndicatorLoader.exe, ref_count=1
Mono: AOT failed to load AOT module /home/jshore/Dev/hf/lib/Debug/IndicatorLoader.exe.so: /home/jshore/Dev/hf/lib/Debug/IndicatorLoader.exe.so: cannot open shared object file: No such file or directory

Mono: Assembly Loader loaded assembly from location: '/home/jshore/Dev/hf/lib/Debug/IndicatorLoader.exe'.
Mono: Config attempting to parse: '/home/jshore/Dev/hf/lib/Debug/IndicatorLoader.exe.config'.
Mono: Config attempting to parse: '/opt/mono-2.11/etc/mono/assemblies/IndicatorLoader/IndicatorLoader.config'.
Mono: Assembly Loader probing location: '/home/jshore/Dev/hf/lib/Debug/IndicatorLoader.exe'.
Mono: AOT failed to load AOT module /home/jshore/Dev/hf/lib/Debug/IndicatorLoader.exe.so: /home/jshore/Dev/hf/lib/Debug/IndicatorLoader.exe.so: cannot open shared object file: No such file or directory

Mono: Assembly Ref addref IndicatorLoader[0x235c4f0] -> mscorlib[0x2288e10]: 2
Mono: Assembly Loader probing location: '/home/jshore/Dev/hf/lib/Debug/com.gf.core.dll'.
Mono: Image addref com.gf.core[0x22e7ef0] -> /home/jshore/Dev/hf/lib/Debug/com.gf.core.dll[0x22e73d0]: 2
Mono: Assembly com.gf.core[0x22e7ef0] added to domain IndicatorLoader.exe, ref_count=1
Mono: AOT failed to load AOT module /home/jshore/Dev/hf/lib/Debug/com.gf.core.dll.so: /home/jshore/Dev/hf/lib/Debug/com.gf.core.dll.so: cannot open shared object file: No such file or directory

Mono: Assembly Loader loaded assembly from location: '/home/jshore/Dev/hf/lib/Debug/com.gf.core.dll'.
Mono: Config attempting to parse: '/home/jshore/Dev/hf/lib/Debug/com.gf.core.dll.config'.
Mono: Config attempting to parse: '/opt/mono-2.11/etc/mono/assemblies/com.gf.core/com.gf.core.config'.
Mono: Assembly Ref addref IndicatorLoader[0x235c4f0] -> com.gf.core[0x22e7ef0]: 2
Mono: Assembly Ref addref com.gf.core[0x22e7ef0] -> mscorlib[0x2288e10]: 3
Mono: Config attempting to parse: '/home/jshore/Dev/hf/lib/Debug/IndicatorLoader.exe.config'.
Mono: Assembly Loader probing location: '/opt/mono-2.11/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll'.
Mono: Image addref System[0x236e220] -> /opt/mono-2.11/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll[0x236d4b0]: 2
Mono: Assembly System[0x236e220] added to domain IndicatorLoader.exe, ref_count=1
Mono: AOT failed to load AOT module /opt/mono-2.11/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll.so: /opt/mono-2.11/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll.so: cannot open shared object file: No such file or directory

Mono: Assembly Loader loaded assembly from location: '/opt/mono-2.11/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll'.
Mono: Config attempting to parse: '/opt/mono-2.11/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll.config'.
Mono: Config attempting to parse: '/opt/mono-2.11/etc/mono/assemblies/System/System.config'.
Mono: Assembly Ref addref com.gf.core[0x22e7ef0] -> System[0x236e220]: 2
Mono: Assembly Ref addref System[0x236e220] -> mscorlib[0x2288e10]: 4
Mono: Assembly Loader probing location: '/opt/mono-2.11/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll'.
Mono: Image addref System.Core[0x238bf00] -> /opt/mono-2.11/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll[0x238b0e0]: 2
Mono: Assembly System.Core[0x238bf00] added to domain IndicatorLoader.exe, ref_count=1
Mono: AOT failed to load AOT module /opt/mono-2.11/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll.so: /opt/mono-2.11/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll.so: cannot open shared object file: No such file or directory

Mono: Assembly Loader loaded assembly from location: '/opt/mono-2.11/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll'.
Mono: Config attempting to parse: '/opt/mono-2.11/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll.config'.
Mono: Config attempting to parse: '/opt/mono-2.11/etc/mono/assemblies/System.Core/System.Core.config'.
Mono: Assembly Ref addref com.gf.core[0x22e7ef0] -> System.Core[0x238bf00]: 2
Mono: Assembly Ref addref System.Core[0x238bf00] -> mscorlib[0x2288e10]: 5
Mono: GC_MINOR: (Nursery full) pause 0.42ms, total 0.43ms, bridge 0.00 promoted 224K major 496K los 135K
Mono: GC_MINOR: ((null)) pause 0.00ms, total 0.00ms, bridge 0.00 promoted 224K major 496K los 135K
Mono: GC_MINOR: (Nursery full) pause 0.30ms, total 0.31ms, bridge 0.00 promoted 32K major 528K los 135K
Mono: GC_MINOR: ((null)) pause 0.00ms, total 0.00ms, bridge 0.00 promoted 32K major 528K los 135K
Mono: GC_MINOR: (Nursery full) pause 0.13ms, total 0.14ms, bridge 0.00 promoted 16K major 544K los 135K
Mono: GC_MINOR: ((null)) pause 0.00ms, total 0.00ms, bridge 0.00 promoted 16K major 544K los 135K
Mono: GC_MINOR: (Nursery full) pause 0.15ms, total 0.16ms, bridge 0.00 promoted 32
Comment 3 Zoltan Varga 2012-09-03 15:15:18 UTC
I get on osx when running a hello world:

* Assertion at sgen-marksweep.c:1778, condition `ms_heap_num_blocks > 0' not met
Comment 4 Jonathan Shore 2012-09-03 15:19:44 UTC
The options I used are valid right?  I took them directly from the sgen web page.  I want to preinitialize the heap to a given size to avoid unnecessary GC while it is growing.
Comment 5 Zoltan Varga 2012-09-03 15:59:24 UTC
Those options are ok, this is a mono bug.
Comment 6 Mark Probst 2012-09-03 16:35:55 UTC
It's an integer overflow.  Try using a smaller number, say "1900m".  I doubt you'd get a heap that large from the OS in any case.

Not to say that it's not an embarrassing bug...
Comment 7 Jonathan Shore 2012-09-03 16:50:31 UTC
@Mark:  I'm curious about the comment re: getting a heap from the OS.  I am running on linux with 16GB of memory on a 65bit kernel and 64bit compilation of mono.  I thought sgen could make use of more than 4GB of memory, unlike the Boehm implementation?
Comment 8 Mark Probst 2012-09-03 16:52:17 UTC
Oh, I'm sorry - that's on 64bit Linux?  Then it's a less trivial issue.  I'll take a look at it.
Comment 9 Jonathan Shore 2012-09-03 16:55:19 UTC
linux is my production platform, but I develop and do research on OSX.  I remember that Miguel said that 2.12 will have a 64bit build for OSX as well?   Looking forward to that day ...
Comment 10 Mark Probst 2012-09-03 17:35:08 UTC
Ok, so which platform do you get this bug on?  Linux 64bit or OSX?  Because I can't reproduce this on Linux 64bit.
Comment 11 Jonathan Shore 2012-09-03 17:49:45 UTC
I am using ubuntu 12.04, with a build of mono off of the head yesterday.


$ /opt/mono-2.11/bin/mono --version
Mono JIT compiler version 2.11.4 (master/5e41a38 Sun Sep  2 14:06:24 PDT 2012)
Copyright (C) 2002-2012 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           __thread
	SIGSEGV:       altstack
	Notifications: epoll
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          yes(3.1svn-mono)
	GC:            Included Boehm (with typed GC and Parallel Mark)
Comment 12 Jonathan Shore 2012-09-03 17:54:14 UTC
The bug appears for any .NET exe I try, for example:

MONO_GC_PARAMS="major=marksweep-fixed,major-heap-size=2g" /opt/mono-2.11/bin/mono --gc=sgen --llvm /opt/mono-2.11/lib/monodevelop

I built LLVM with:

./configure --prefix=/opt/mono-2.11 --enable-optimized --enable-targets="x86 x86_64"

I built mono with:

./autogen.sh --prefix=/opt/mono-2.11 --enable-llvm=yes --enable-loadedllvm
Comment 13 Miguel de Icaza [MSFT] 2012-09-03 21:29:49 UTC
Mono builds on OSX/64 bits, but we are no plans on shipping a Mono/OSX/64 bit until we have all of the UI libraries ported to 64 bits, and that is no small feat.

Specially since UIKit/Foundation aliased "NSInteger" to be "int32_t" on 32 bit systems and "int64_t" on 64 bit systems, a problem that will require a massive audit of very large code bases.

So nobody should expect an out-of-the-box 64 bit Mono on OSX.    Only advanced users that are willing to use Mono for headless work and build their own will have that.
Comment 14 Jonathan Shore 2012-09-04 09:22:30 UTC
@Miguel:  fair enough.  Thanks for the update.  I compiled some older version of mono 64bit on osx and I think that caused issues with monodevelop.   Although I have no mono UI applications, since I rely on monodevelop.  

Perhaps I can build a 64bit version that does not interfere with the main build that monodevelop uses.
Comment 15 Miguel de Icaza [MSFT] 2012-09-04 09:54:29 UTC
Yes, you can.

Details: http://www.mono-project.com/Parallel_Mono_Environments
Comment 16 Mark Probst 2012-09-05 09:25:51 UTC
Fixed in master.  Heap sizes that don't fit in the signed long type (>=2gb on 32 bits) won't be accepted on the command line.
Comment 17 Jonathan Shore 2012-09-05 09:45:22 UTC
Can you clarify the fix here.  I was running this on a 64bit system / 64bit build, so signed long value should be 2^63 bits.  I was not testing the param on a 32 bit build.

Is the adjustment here just to check to see whether major-heap-size=2g is viable for the system?  Because if that is all that has changed, then the bug still exists for 64 bit build (?)
Comment 18 Mark Probst 2012-09-06 14:07:32 UTC
I fixed bugs in a few places relevant to this, including parsing of the heap size number and reporting bugs.  Please give master a try - it should work now, and if the heap cannot be allocated then it should report an error (instead of crashing, as it would have done previously).