{"record":{"id":"339835c6cedf8c1e","repo":"mono/mono","slug":"error-bisect-requires-opt-filename","errorCode":null,"errorMessage":"Error: --bisect requires OPT:FILENAME\n","messagePattern":"Error: --bisect requires OPT:FILENAME\n","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mono/mini/driver.c","lineNumber":2210,"sourceCode":"\t\t\treturn 0;\n\t\t} else if (strcmp (argv [i], \"--list-opt\") == 0){\n\t\t\tmini_usage_list_opt ();\n\t\t\treturn 0;\n\t\t} else if (strncmp (argv [i], \"--statfile\", 10) == 0) {\n\t\t\tif (i + 1 >= argc){\n\t\t\t\tfprintf (stderr, \"error: --statfile requires a filename argument\\n\");\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tmini_stats_fd = fopen (argv [++i], \"w+\");\n\t\t} else if (strncmp (argv [i], \"--optimize=\", 11) == 0) {\n\t\t\topt = parse_optimizations (opt, argv [i] + 11, TRUE);\n\t\t} else if (strncmp (argv [i], \"-O=\", 3) == 0) {\n\t\t\topt = parse_optimizations (opt, argv [i] + 3, TRUE);\n\t\t} else if (strncmp (argv [i], \"--bisect=\", 9) == 0) {\n\t\t\tchar *param = argv [i] + 9;\n\t\t\tchar *sep = strchr (param, ':');\n\t\t\tif (!sep) {\n\t\t\t\tfprintf (stderr, \"Error: --bisect requires OPT:FILENAME\\n\");\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tchar *opt_string = g_strndup (param, sep - param);\n\t\t\tguint32 opt = parse_optimizations (0, opt_string, FALSE);\n\t\t\tg_free (opt_string);\n\t\t\tmono_set_bisect_methods (opt, sep + 1);\n\t\t} else if (strcmp (argv [i], \"--gc=sgen\") == 0) {\n\t\t\tswitch_gc (argv, \"sgen\");\n\t\t} else if (strcmp (argv [i], \"--gc=boehm\") == 0) {\n\t\t\tswitch_gc (argv, \"boehm\");\n\t\t} else if (strncmp (argv[i], \"--gc-params=\", 12) == 0) {\n\t\t\tmono_gc_params_set (argv[i] + 12);\n\t\t} else if (strncmp (argv[i], \"--gc-debug=\", 11) == 0) {\n\t\t\tmono_gc_debug_set (argv[i] + 11);\n\t\t}\n#ifdef TARGET_OSX\n\t\telse if (strcmp (argv [i], \"--arch=32\") == 0) {\n\t\t\tswitch_arch (argv, \"32\");","sourceCodeStart":2192,"sourceCodeEnd":2228,"githubUrl":"https://github.com/mono/mono/blob/0f53e9e151d92944cacab3e24ac359410c606df6/mono/mini/driver.c#L2192-L2228","documentation":"`--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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Format the value as `OPT:FILENAME`, e.g. `mono --bisect=inline:/tmp/bisect.txt prog.exe`.","Use a comma-separated opt list before the colon: `--bisect=inline,cfold:/tmp/bisect.txt`.","Verify the opt names are valid (see `mono --list-opt`); an unknown name makes parse_optimizations print 'Invalid optimization name' and exit."],"exampleFix":"# before\nmono --bisect=inline MyProgram.exe\n# after\nmono --bisect=inline:/tmp/bisect.txt MyProgram.exe","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nval=\"${1#--bisect=}   # after stripping the prefix\nif [[ \"$val\" != *:* ]]; then\n  echo \"--bisect needs OPT:FILENAME\" >&2; exit 1\nfi\nopt=\"${val%%:*}\"; file=\"${val#*:}\"\n[[ -n \"$opt\" && -n \"$file\" ]] || { echo \"empty OPT or FILENAME\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Construct the value explicitly: \"--bisect=${opt}:${outfile}\".","Validate the opt names against `mono --list-opt` before launching.","Use a colon as the sole separator; never semicolon or pipe."],"tags":["cli","mono","argument-validation","jit","bisect"],"backgroundTag":null,"analyzedSha":"0f53e9e151d92944cacab3e24ac359410c606df6","analyzedAt":"2026-08-13T18:54:37.190Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}