{"record":{"id":"21faefe8a0fb3b07","repo":"NationalSecurityAgency/ghidra","slug":"cannot-locate-schema-xml","errorCode":null,"errorMessage":"cannot locate schema.xml","messagePattern":"cannot locate schema\\.xml","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"critical","filePath":"Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/commands.py","lineNumber":226,"sourceCode":"    \"\"\"Disconnect Python from Ghidra for tracing\"\"\"\n\n    STATE.require_client().close()\n    STATE.reset_client()\n\n\ndef start_trace(name: str) -> None:\n    language, compiler = arch.compute_ghidra_lcsp()\n    if name is None:\n        name = 'drgn/noname'\n    STATE.trace = STATE.require_client().create_trace(\n        name, language, compiler, extra=Extra())\n    # TODO: Is adding an attribute like this recommended in Python?\n    STATE.trace.extra.memory_mapper = arch.compute_memory_mapper(language)\n    STATE.trace.extra.register_mapper = arch.compute_register_mapper(language)\n\n    frame = inspect.currentframe()\n    if frame is None:\n        raise AssertionError(\"cannot locate schema.xml\")\n    parent = os.path.dirname(inspect.getfile(frame))\n    schema_fn = os.path.join(parent, 'schema.xml')\n    with open(schema_fn, 'r') as schema_file:\n        schema_xml = schema_file.read()\n    with STATE.trace.open_tx(\"Create Root Object\"):\n        root = STATE.trace.create_root_object(schema_xml, 'DrgnRoot')\n        root.set_value('_display',  'drgn version ' + util.DRGN_VERSION.full)\n    util.set_convenience_variable('_ghidra_tracing', \"true\")\n\n\ndef ghidra_trace_start(name: str = \"drgn/noname\") -> None:\n    \"\"\"Start a Trace in Ghidra\"\"\"\n\n    STATE.require_client()\n    STATE.require_no_trace()\n    start_trace(name)\n\n","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/NationalSecurityAgency/ghidra/blob/d5f144c24d6bc53c9cbf4448c6d11143e7696206/Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/commands.py#L208-L244","documentation":"Thrown as an AssertionError by start_trace in the drgn agent when inspect.currentframe() returns None, preventing the code from locating the directory that contains schema.xml. The frame is used to derive the filesystem path to the bundled schema.xml file via inspect.getfile(frame). In practice this is nearly impossible under standard CPython.","triggerScenarios":"Running the drgn agent under a Python implementation or environment where inspect.currentframe() returns None — certain restricted/embedded interpreters, some JIT-compiled or optimized environments, or environments where frame inspection is disabled. This is an extremely rare condition.","commonSituations":"Virtually never occurs under standard CPython. Could theoretically manifest in heavily restricted sandboxes, microcontroller Python ports (MicroPython/CircuitPython), or environments where sys._getframe is unavailable. If you see this, the Python runtime itself is non-standard.","solutions":["Use a standard CPython interpreter (CPython 3.x) for running the drgn agent.","If in a restricted environment, ensure frame inspection is not disabled (do not set sys.tracebacklimit=0 or use -O in ways that strip frames).","As a workaround, verify that schema.xml exists alongside commands.py in the ghidradrgn package directory."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"import inspect, os\n\ndef verify_schema_available() -> bool:\n    frame = inspect.currentframe()\n    if frame is None:\n        return False\n    parent = os.path.dirname(inspect.getfile(frame))\n    return os.path.isfile(os.path.join(parent, 'schema.xml'))","typeGuard":null,"tryCatchPattern":"try:\n    start_trace(name)\nexcept AssertionError as e:\n    if 'schema.xml' in str(e):\n        print('Frame inspection unavailable in this Python runtime. Use standard CPython.')\n    raise","preventionTips":["Run the drgn agent under standard CPython — frame inspection is guaranteed.","Do not use Python optimization flags that strip frames.","Verify schema.xml is packaged alongside commands.py in the installation."],"tags":["drgn","assertion","runtime-environment","schema"],"backgroundTag":null,"analyzedSha":"d5f144c24d6bc53c9cbf4448c6d11143e7696206","analyzedAt":"2026-08-14T01:00:57.564Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}