NationalSecurityAgency/ghidra · critical · AssertionError

cannot locate schema.xml

Error message

cannot locate schema.xml

What it means

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.

Source

Thrown at Ghidra/Debug/Debugger-agent-drgn/src/main/py/src/ghidradrgn/commands.py:226

    """Disconnect Python from Ghidra for tracing"""

    STATE.require_client().close()
    STATE.reset_client()


def start_trace(name: str) -> None:
    language, compiler = arch.compute_ghidra_lcsp()
    if name is None:
        name = 'drgn/noname'
    STATE.trace = STATE.require_client().create_trace(
        name, language, compiler, extra=Extra())
    # TODO: Is adding an attribute like this recommended in Python?
    STATE.trace.extra.memory_mapper = arch.compute_memory_mapper(language)
    STATE.trace.extra.register_mapper = arch.compute_register_mapper(language)

    frame = inspect.currentframe()
    if frame is None:
        raise AssertionError("cannot locate schema.xml")
    parent = os.path.dirname(inspect.getfile(frame))
    schema_fn = os.path.join(parent, 'schema.xml')
    with open(schema_fn, 'r') as schema_file:
        schema_xml = schema_file.read()
    with STATE.trace.open_tx("Create Root Object"):
        root = STATE.trace.create_root_object(schema_xml, 'DrgnRoot')
        root.set_value('_display',  'drgn version ' + util.DRGN_VERSION.full)
    util.set_convenience_variable('_ghidra_tracing', "true")


def ghidra_trace_start(name: str = "drgn/noname") -> None:
    """Start a Trace in Ghidra"""

    STATE.require_client()
    STATE.require_no_trace()
    start_trace(name)

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Use a standard CPython interpreter (CPython 3.x) for running the drgn agent.
  2. 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).
  3. As a workaround, verify that schema.xml exists alongside commands.py in the ghidradrgn package directory.
Defensive patterns

Strategy: fallback

Validate before calling

import inspect, os

def verify_schema_available() -> bool:
    frame = inspect.currentframe()
    if frame is None:
        return False
    parent = os.path.dirname(inspect.getfile(frame))
    return os.path.isfile(os.path.join(parent, 'schema.xml'))

Try / catch

try:
    start_trace(name)
except AssertionError as e:
    if 'schema.xml' in str(e):
        print('Frame inspection unavailable in this Python runtime. Use standard CPython.')
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/21faefe8a0fb3b07. Report an issue: GitHub.