Bug 12010 - mono option --gc=sgen is silently ignored
Summary: mono option --gc=sgen is silently ignored
Status: RESOLVED FIXED
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
URL:
Depends on:
Blocks:
 
Reported: 2013-04-28 07:24 UTC by Tobias Brandt
Modified: 2014-02-06 01:32 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 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:
Status:
RESOLVED FIXED

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

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
@Andres:

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

---------------------------------------------------------------------------
#!/usr/bin/env bash

#Workaround for Unity gnome shell
export UBUNTU_MENUPROXY=0

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


#this script should be in $PREFIX/bin
MONO_EXEC="exec mono -a monodevelop"
EXE_PATH="${0%%/bin/monodevelop}/lib/monodevelop/bin/MonoDevelop.exe"

_MD_REDIRECT_LOG="${MD_REDIRECT_LOG:-${XDG_CONFIG_HOME:-$HOME/.config}/MonoDevelop/log}"

##NOTE: remove this for stable releases
if [ -z "$MD_NO_DEBUG" ]; then
        _MONO_OPTIONS=${MONO_OPTIONS:---debug}
else
        _MONO_OPTIONS=$MONO_OPTIONS
fi

if [ -n "$_MD_REDIRECT_LOG" ]; then
        mkdir -p `dirname "$_MD_REDIRECT_LOG"`
    $MONO_EXEC $_MONO_OPTIONS "$EXE_PATH" $* 2>&1 | tee "$_MD_REDIRECT_LOG"
else
        $MONO_EXEC $_MONO_OPTIONS "$EXE_PATH" $*
fi
---------------------------------------------------------------------------


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?