{"record":{"id":"7d16f3d867b152a2","repo":"dotnet/runtime","slug":"error-toc-file-not-created-correctly-at-s","errorCode":null,"errorMessage":"Error, toc file not created correctly at: %s","messagePattern":"Error, toc file not created correctly at: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/coreclr/scripts/superpmi.py","lineNumber":1463,"sourceCode":"        if not self.coreclr_args.skip_cleanup:\n            if os.path.isfile(self.base_mch_file):\n                os.remove(self.base_mch_file)\n                self.base_mch_file = None\n\n    def __create_toc__(self):\n        \"\"\" Create a TOC file\n\n        Notes:\n            <mcl> -toc <s_finalMchFile>\n        \"\"\"\n\n        logging.info(\"Creating TOC file\")\n\n        command = [self.mcs_path, \"-toc\", self.final_mch_file]\n        run_and_log(command)\n\n        if not os.path.isfile(self.toc_file):\n            raise RuntimeError(\"Error, toc file not created correctly at: %s\" % self.toc_file)\n\n    def __verify_final_mch__(self):\n        \"\"\" Verify the resulting MCH file is error-free when running SuperPMI against it with the same JIT used for collection.\n\n        Notes:\n            <SuperPmiPath> -p -f <s_finalFailMclFile> <s_finalMchFile> <jitPath>\n        \"\"\"\n\n        logging.info(\"Verifying MCH file\")\n\n        mch_files = [ self.final_mch_file ]\n        spmi_replay = SuperPMIReplay(self.coreclr_args, mch_files, self.jit_path)\n        passed = spmi_replay.replay()\n\n        if not passed:\n            raise RuntimeError(\"Error, unclean replay.\")\n\n    def __process_for_ci__(self):","sourceCodeStart":1445,"sourceCodeEnd":1481,"githubUrl":"https://github.com/dotnet/runtime/blob/290d5ab72cc1102813fbc0406fb186ceadabc340/src/coreclr/scripts/superpmi.py#L1445-L1481","documentation":"Raised in `__create_toc__` (superpmi.py:1462-1463) after running `mcs -toc <final.mch>`. The TOC file is `final_mch_file + '.mct'`; if it is not present after the command, the TOC generation failed. The TOC is required for indexed/random access into the MCH during replay.","triggerScenarios":"The `mcs -toc` command ran but did not create the `.mct` file beside the final MCH. Causes: mcs error on a corrupt/empty final MCH, missing final MCH (errors 166/167), or a write/permission failure.","commonSituations":"final_mch_file is zero-length or corrupt from a bad merge/clean; mcs binary version mismatch; the MCH directory is read-only so the `.mct` cannot be written.","solutions":["Confirm final_mch_file is a valid non-empty MCH (errors 166/167 did not occur).","Inspect the logged `mcs -toc` output for the mcs return code/error.","Ensure the final MCH directory is writable and has disk space, then re-run with `--skip_collection_step --skip_merge_step`."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"# Confirm the final MCH is valid before invoking the toc step\nif not os.path.isfile(final_mch_file) or os.path.getsize(final_mch_file) == 0:\n    raise SystemExit('final MCH missing/empty; cannot create TOC.')","typeGuard":null,"tryCatchPattern":"try:\n    collection.__create_toc__()\nexcept RuntimeError as e:\n    if 'toc file not created' in str(e):\n        logging.error('mcs -toc failed; verify final MCH integrity and mcs output.')\n    raise","preventionTips":["Validate final MCH before toc creation.","Ensure the MCH directory is writable for the .mct output."],"tags":["mch","toc","superpmi","diagnostics"],"analyzedSha":"290d5ab72cc1102813fbc0406fb186ceadabc340","analyzedAt":"2026-08-06T19:57:01.276Z","schemaVersion":2},"datasetVersion":"2026-08-06T23:17:07.152Z"}