mono/mono · error

Error: --bisect requires OPT:FILENAME

Error message

Error: --bisect requires OPT:FILENAME

What it means

`--bisect=OPT:FILENAME` enables JIT bisection to find which optimization breaks a method. After matching the `--bisect=` prefix, the driver takes the remainder (`argv[i]+9`), searches for a `:` separator with strchr, and if none is found prints this error and exits 1. Both the optimization list (parsed by parse_optimizations) and the output filename must be present in the single `OPT:FILENAME` token, separated by exactly one colon.

Source

Thrown at mono/mini/driver.c:2210

			return 0;
		} else if (strcmp (argv [i], "--list-opt") == 0){
			mini_usage_list_opt ();
			return 0;
		} else if (strncmp (argv [i], "--statfile", 10) == 0) {
			if (i + 1 >= argc){
				fprintf (stderr, "error: --statfile requires a filename argument\n");
				return 1;
			}
			mini_stats_fd = fopen (argv [++i], "w+");
		} else if (strncmp (argv [i], "--optimize=", 11) == 0) {
			opt = parse_optimizations (opt, argv [i] + 11, TRUE);
		} else if (strncmp (argv [i], "-O=", 3) == 0) {
			opt = parse_optimizations (opt, argv [i] + 3, TRUE);
		} else if (strncmp (argv [i], "--bisect=", 9) == 0) {
			char *param = argv [i] + 9;
			char *sep = strchr (param, ':');
			if (!sep) {
				fprintf (stderr, "Error: --bisect requires OPT:FILENAME\n");
				return 1;
			}
			char *opt_string = g_strndup (param, sep - param);
			guint32 opt = parse_optimizations (0, opt_string, FALSE);
			g_free (opt_string);
			mono_set_bisect_methods (opt, sep + 1);
		} else if (strcmp (argv [i], "--gc=sgen") == 0) {
			switch_gc (argv, "sgen");
		} else if (strcmp (argv [i], "--gc=boehm") == 0) {
			switch_gc (argv, "boehm");
		} else if (strncmp (argv[i], "--gc-params=", 12) == 0) {
			mono_gc_params_set (argv[i] + 12);
		} else if (strncmp (argv[i], "--gc-debug=", 11) == 0) {
			mono_gc_debug_set (argv[i] + 11);
		}
#ifdef TARGET_OSX
		else if (strcmp (argv [i], "--arch=32") == 0) {
			switch_arch (argv, "32");

View on GitHub (pinned to 0f53e9e151)

Solutions

  1. Format the value as `OPT:FILENAME`, e.g. `mono --bisect=inline:/tmp/bisect.txt prog.exe`.
  2. Use a comma-separated opt list before the colon: `--bisect=inline,cfold:/tmp/bisect.txt`.
  3. Verify the opt names are valid (see `mono --list-opt`); an unknown name makes parse_optimizations print 'Invalid optimization name' and exit.

Example fix

# before
mono --bisect=inline MyProgram.exe
# after
mono --bisect=inline:/tmp/bisect.txt MyProgram.exe
Defensive patterns

Strategy: validation

Validate before calling

#!/usr/bin/env bash
val="${1#--bisect=}   # after stripping the prefix
if [[ "$val" != *:* ]]; then
  echo "--bisect needs OPT:FILENAME" >&2; exit 1
fi
opt="${val%%:*}"; file="${val#*:}"
[[ -n "$opt" && -n "$file" ]] || { echo "empty OPT or FILENAME" >&2; exit 1; }

Prevention

When it happens

Trigger: Passing `--bisect=inline` (no colon, no filename), `--bisect=inline;out.txt` (wrong separator), or `--bisect=:file` / `--bisect=opt:` (empty half — the colon exists but one side is empty, which passes this check but fails later in parse_optimizations or file open).

Common situations: Users assuming `--bisect` takes two separate args like other flags; using a semicolon or pipe instead of a colon; forgetting the filename portion when reproducing a regression.

Related errors


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