{"record":{"id":"3c05b9bf93c2299e","repo":"antlr/antlr4","slug":"antlr-panic","errorCode":null,"errorMessage":"ANTLR panic","messagePattern":"ANTLR panic","errorType":"panic","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"tool/src/org/antlr/v4/Tool.java","lineNumber":967,"sourceCode":"\t\tif ( listeners.isEmpty() ) {\n\t\t\tdefaultListener.warning(msg);\n\t\t}\n\t\telse {\n\t\t\tfor (ANTLRToolListener l : listeners) l.warning(msg);\n\t\t}\n\n\t\tif (warnings_are_errors) {\n\t\t\terrMgr.emit(ErrorType.WARNING_TREATED_AS_ERROR, new ANTLRMessage(ErrorType.WARNING_TREATED_AS_ERROR));\n\t\t}\n\t}\n\n\tpublic void version() {\n\t\tinfo(\"ANTLR Parser Generator  Version \" + VERSION);\n\t}\n\n\tpublic void exit(int e) { System.exit(e); }\n\n\tpublic void panic() { throw new Error(\"ANTLR panic\"); }\n\n}\n","sourceCodeStart":949,"sourceCodeEnd":970,"githubUrl":"https://github.com/antlr/antlr4/blob/7d5770395bb7b02eb56e7c62662cb1d7c08f42a3/tool/src/org/antlr/v4/Tool.java#L949-L970","documentation":"Tool.panic() is the ANTLR tool's last-resort abort: it throws java.lang.Error('ANTLR panic') for unrecoverable internal failures. Error (not Exception) is deliberate so it bypasses normal catch blocks; in the tool it is typically reached via the ErrorManager after fatal error conditions.","triggerScenarios":"Internal invariant violations during grammar compilation, or ErrorManager panic paths routing here; also user code calling tool.panic() directly.","commonSituations":"Corrupt/incompatible grammar metadata, severe tool bugs, or customized Tool subclasses that call panic(); sometimes surfaced when error limits (ERROR_MANAGER punishing fatal errors) are exceeded.","solutions":["Capture the tool output/errors immediately preceding the panic — the real cause is logged before it","Reproduce with the same grammar on the latest ANTLR release; if it persists, report with a minimal grammar","Do not catch Error in build scripts; fix the underlying fatal error instead"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { tool.processGrammars(args); } catch (Error e) { /* ANTLR panic: capture preceding tool output for root cause */ }","preventionTips":["Run the tool with output captured so pre-panic diagnostics are retained","Keep tool and runtime versions aligned","Report minimal reproducible grammars upstream"],"tags":["antlr","tool","fatal","java"],"backgroundTag":null,"analyzedSha":"7d5770395bb7b02eb56e7c62662cb1d7c08f42a3","analyzedAt":"2026-08-14T14:47:56.354Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}