Skip to content

Error BinExporting #8

@monoidic

Description

@monoidic

After analyzing some Linux binaries with this plugin, they are no longer able to be exported using BinExport, for use with BinDiff. If this plugin is not used during analysis, then they remain exportable.

I haven't debugged this in too much depth, but it appears that at least the net package triggers this, both with the cgo and netgo variant.

Code:

package main

import "net"

func main() {
	_, _ = net.Listen("", "")
}

Stack trace:

2025-02-25	13:37:00	ERROR	(ExportTask) Exception exporting java.lang.UnsupportedOperationException: Storage does not have a stack varnode
			at ghidra.program.model.listing.VariableStorage.getStackOffset(VariableStorage.java:510)
			at ghidra.program.database.function.VariableDB.getStackOffset(VariableDB.java:310)
			at ghidra.program.model.listing.VariableOffset.<init>(VariableOffset.java:78)
			at ghidra.program.model.listing.CodeUnitFormat.getVariableReferenceRepresentation(CodeUnitFormat.java:1128)
			at ghidra.program.model.listing.CodeUnitFormat.markupScalarWithStackReference(CodeUnitFormat.java:728)
			at ghidra.program.model.listing.CodeUnitFormat.performScalarMarkup(CodeUnitFormat.java:529)
			at ghidra.program.model.listing.CodeUnitFormat.getOperandRepresentationList(CodeUnitFormat.java:245)
			at ghidra.program.model.listing.CodeUnitFormat.getOperandRepresentationString(CodeUnitFormat.java:178)
			at com.google.security.binexport.BinExport2Builder.buildInstructionOperands(BinExport2Builder.java:550)
			at com.google.security.binexport.BinExport2Builder.buildInstructions(BinExport2Builder.java:669)
			at com.google.security.binexport.BinExport2Builder.build(BinExport2Builder.java:1132)
			at com.google.security.binexport.BinExportExporter.export(BinExportExporter.java:103)
			at ghidra.app.plugin.core.exporter.ExporterDialog$ExportTask.run(ExporterDialog.java:578)
			at ghidra.util.task.Task.monitoredRun(Task.java:134)
			at ghidra.util.task.TaskRunner.lambda$startTaskThread$0(TaskRunner.java:106)
			at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
			at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
			at java.base/java.lang.Thread.run(Thread.java:1583)

A simple hello world seems to exhibit a different exception later.
Code:

package main

import "fmt"

func main() {
	fmt.Println("hello world")
}

Stack trace:

2025-02-25	14:20:00	ERROR	(ExportTask) Exception exporting java.lang.NullPointerException: Cannot invoke "ghidra.program.model.listing.Instruction.getAddress()" because "instr" is null
			at com.google.security.binexport.BinExport2Builder.getMappedAddress(BinExport2Builder.java:130)
			at com.google.security.binexport.BinExport2Builder.buildFlowGraphs(BinExport2Builder.java:773)
			at com.google.security.binexport.BinExport2Builder.build(BinExport2Builder.java:1142)
			at com.google.security.binexport.BinExportExporter.export(BinExportExporter.java:103)
			at ghidra.app.plugin.core.exporter.ExporterDialog$ExportTask.run(ExporterDialog.java:578)
			at ghidra.util.task.Task.monitoredRun(Task.java:134)
			at ghidra.util.task.TaskRunner.lambda$startTaskThread$0(TaskRunner.java:106)
			at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
			at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
			at java.base/java.lang.Thread.run(Thread.java:1583)

I'll try to have a look at this myself later as well, though I hope this isn't too niche an issue to look into.

Setup:
Ghidra 11.3.1, Linux official binary release, w/ OpenJDK 21
BinExport at version 12 (latest release) or current latest release from CI (11.1.2 here)
Binaries: as described above. Provided here for convenience.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions