mono/mono · error

Syntax error; expected debug option name

Error message

Syntax error; expected debug option name

What it means

Emitted by parse_debug_options at the very first iteration when the option string is empty (the loop's do { } encounters an empty string, i.e. *p == '\0' immediately). It indicates the --debug= value parsed to nothing before any option name was read, and returns FALSE, which makes the option fall through to the 'Unsupported command line option' handler.

Source

Thrown at mono/mini/driver.c:208

				exit (1);
			}
		}

		g_free (arg);
	}
	g_free (parts);

	return opt;
}

static gboolean
parse_debug_options (const char* p)
{
	MonoDebugOptions *opt = mini_get_debug_options ();

	do {
		if (!*p) {
			fprintf (stderr, "Syntax error; expected debug option name\n");
			return FALSE;
		}

		if (!strncmp (p, "casts", 5)) {
			opt->better_cast_details = TRUE;
			p += 5;
		} else if (!strncmp (p, "mdb-optimizations", 17)) {
			opt->mdb_optimizations = TRUE;
			p += 17;
		} else if (!strncmp (p, "gdb", 3)) {
			opt->gdb = TRUE;
			p += 3;
		} else {
			fprintf (stderr, "Invalid debug option `%s', use --help-debug for details\n", p);
			return FALSE;
		}

		if (*p == ',') {

View on GitHub (pinned to 0f53e9e151)

Solutions

  1. Provide at least one valid debug option name, e.g. --debug=casts or --debug=gdb.
  2. If DEBUG_OPTS may be empty, omit the flag entirely rather than passing --debug=.
  3. Strip leading commas before passing the value.

Example fix

# before
DEBUG_OPTS=""; mono --debug=$DEBUG_OPTS app.exe
# after
DEBUG_OPTS="casts"; mono --debug=$DEBUG_OPTS app.exe
Defensive patterns

Strategy: validation

Validate before calling

# Never pass an empty --debug= value
[ -n "$DEBUG_OPTS" ] || unset DEBUG_OPTS
[ -z "${DEBUG_OPTS##,*}" ] && DEBUG_OPTS="${DEBUG_OPTS#,}"   # strip leading comma
mono ${DEBUG_OPTS:+--debug=$DEBUG_OPTS} app.exe

Prevention

When it happens

Trigger: Passing --debug= with an empty value, or --debug followed by a value that strips to empty. The parser expects at least one recognized token (casts, mdb-optimizations, gdb, ...).

Common situations: A shell variable expanding to empty in --debug=$DEBUG_OPTS; a stray equals sign; misconfigured debug option in a Docker entrypoint.

Related errors


AI-assisted analysis of mono/mono@0f53e9e151 (2026-08-13). Data as JSON: /api/errors/3d7a2f9b4dc5b45c. Report an issue: GitHub.