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 gdb agent when inspect.currentframe() returns None, preventing the code from deriving the path to schema.xml. The frame is used to find the package directory containing schema.xml via inspect.getfile(frame). Under standard CPython this is essentially unreachable.

Source

Thrown at Ghidra/Debug/Debugger-agent-gdb/src/main/py/src/ghidragdb/commands.py:298

def compute_name() -> str:
    progname = gdb.selected_inferior().progspace.filename
    if progname is None:
        return 'gdb/noname'
    else:
        return 'gdb/' + re.split(r'(/|\\)', progname)[-1]


def start_trace(name: str) -> None:
    language, compiler = arch.compute_ghidra_lcsp()
    STATE.trace = STATE.require_client().create_trace(
        name, language, compiler, extra=Extra())
    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, 'GdbSession')
        root.set_value('_display', 'GNU gdb ' + util.GDB_VERSION.full)
        STATE.trace.create_object(AVAILABLES_PATH).insert()
        STATE.trace.create_object(BREAKPOINTS_PATH).insert()
        STATE.trace.create_object(INFERIORS_PATH).insert()
    gdb.set_convenience_variable('_ghidra_tracing', True)


@cmd('ghidra trace start', '-ghidra-trace-start', gdb.COMMAND_DATA, False)
def ghidra_trace_start(name: Optional[str] = None, *, is_mi: bool,
                       **kwargs) -> None:

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Run the gdb agent under standard CPython (GDB's built-in Python is CPython).
  2. Ensure frame inspection is not disabled in the Python runtime.
  3. Verify schema.xml exists in the same directory as commands.py in the ghidragdb package.
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. Use standard CPython via GDB.')
    raise

Prevention

When it happens

Trigger: Running the gdb agent Python code under a non-standard interpreter or restricted environment where inspect.currentframe() returns None. This is the gdb-side equivalent of error 163 and is equally rare.

Common situations: Effectively never occurs under standard CPython or GDB's embedded Python. Could theoretically arise in sandboxed or embedded Python environments where frame introspection is disabled.

Related errors


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