-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Open
Description
Describe the bug
While using PyGhidra on Ghidra's master branch, I got:
Traceback (most recent call last):
File "ghidra_analyze_and_export_programs.py", line 105, in analyze_and_export_all_programs
pyghidra.analyze(program)
~~~~~~~~~~~~~~~~^^^^^^^^^
File "/root/.config/ghidra/ghidra_12.1_DEV/venv/lib/python3.13/site-packages/pyghidra/api.py", line 177, in analyze
monitor = monitor()
TypeError: 'NoneType' object is not callable
To Reproduce
Steps to reproduce the behavior:
- On Debian 13, build and install Ghidra's current
masterbranch (commita0acfb8f914f77dd72a1a6661d501f758eef0a90, 12.1 DEV) - Launch
support/pyghidraRun - In another terminal, launch a Python interactive console using PyGhidra's virtual environment with
~/.config/ghidra/ghidra_12.1_DEV/venv/bin/python3 - Analyze some program, like
/bin/trueby entering the following Python code:
import pyghidra
pyghidra.start()
project = pyghidra.open_project("/tmp", "my_project", create=True)
loaded_program = pyghidra.program_loader().project(project).source("/bin/true").load()
program = loaded_program.getPrimaryDomainObject()
pyghidra.analyze(program)- Observe a Python exception
Traceback (most recent call last):
File "<python-input-6>", line 1, in <module>
pyghidra.analyze(program)
~~~~~~~~~~~~~~~~^^^^^^^^^
File "/root/.config/ghidra/ghidra_12.1_DEV/venv/lib/python3.13/site-packages/pyghidra/api.py", line 177, in analyze
monitor = monitor()
TypeError: 'NoneType' object is not callable
Expected behavior
No error
Screenshots
If applicable, add screenshots to help explain your problem.
Environment (please complete the following information):
- OS: Debian 13 with x86_64 CPU
- Java Version: OpenJDK Runtime Environment (build 21.0.9+10-Debian-1deb13u1)
- Ghidra Version: current
master - Ghidra Origin: Locally built from https://github.com/NationalSecurityAgency/ghidra
Additional context
Add any other context about the problem here.
This regression comes from commit c18c7a8 which modified pyghidra.api.analyze to:
def analyze(
program: "Program",
monitor: Optional["TaskMonitor"] = None
):
"""
Analyzes the given program.
:param program: The Ghidra program to analyze.
"""
from ghidra.app.script import GhidraScriptUtil
from ghidra.program.util import GhidraProgramUtilities
from ghidra.app.plugin.core.analysis import AutoAnalysisManager
if monitor is None:
monitor = monitor()In the last line, monitor is a local variable which is None, so calling monitor() triggers the error.
Metadata
Metadata
Assignees
Labels
No labels