Bug 12010 - mono option --gc=sgen is silently ignored
Summary: mono option --gc=sgen is silently ignored
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: General ()
Version: 4.0
Hardware: PC Linux
: --- normal
Target Milestone: 4.2.3 (from master)
Assignee: Bugzilla
Depends on:
Reported: 2013-04-28 07:24 UTC by Tobias Brandt
Modified: 2014-02-06 01:32 UTC (History)
4 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 on Developer Community or GitHub 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:

Description Tobias Brandt 2013-04-28 07:24:59 UTC

MONO_OPTIONS=--gc=sgen monodevelop

does not activate the sgen GC.

The reason is that the monodevelop start-up script uses the -a option of exec (line 11) to rename the process from "mono" to "monodevelop".
Mono parses the --gc=sgen option and then appends "-sgen" to argv[0] (mono/mini/driver.c, line 1513, in git commit tagged mono-3.10).
It then tries to replace itself using execvp(argv[0], argv), expecting argv[0] to be "mono-sgen".
But in reality argv[0] is "monodevelop-sgen" which doesn't exists. So the function returns with an error code, no error is printed, and mono continues to use boehm.

A quick fix is to remove "-a monodevelop" from the start-up script

This might also be considered a bug in mono.
Comment 1 Andres G. Aragoneses 2013-04-29 19:18:49 UTC
I think it should be MONO_ENV_OPTIONS, not MONO_OPTIONS.
Comment 2 Tobias Brandt 2013-05-01 05:53:48 UTC

The script that's installed in $PREFIX/bin/monodevelop passes MONO_OPTIONS:

#!/usr/bin/env bash

#Workaround for Unity gnome shell

# Ubuntu overlay scrollbars are not working well with the 1px boundaries in the monodevelop shell

#this script should be in $PREFIX/bin
MONO_EXEC="exec mono -a monodevelop"


##NOTE: remove this for stable releases
if [ -z "$MD_NO_DEBUG" ]; then

if [ -n "$_MD_REDIRECT_LOG" ]; then
        mkdir -p `dirname "$_MD_REDIRECT_LOG"`

I don't know if that's intended or not, but replacing it with MONO_ENV_OPTIONS will not fix the bug as far as I can see.
Comment 3 Andres G. Aragoneses 2013-09-03 15:24:30 UTC
Exactly, MONO_OPTIONS is an env var used by the script, not by mono.

Mono uses $MONO_ENV_OPTIONS to gather more flags.

If what you mean is that there is a bug in monodevelop's shell script, then ignore comment#1, I have nothing to say. (To check this, you could just add an "echo" statement in the script, to see what's happening.)
Comment 4 Mikayla Hutchinson [MSFT] 2013-09-03 17:16:57 UTC
Fixed, the script always uses mono-sgen now.
Comment 5 narayanp 2014-02-06 01:32:56 UTC
Could you please provide me some steps or test project so that I can verify this issue?